C++20's new `using enum` feature. Syntax and possible use cases.
#cppweekly #cplusplushttps://youtu.be/JM8F2DPm_0E
-
-
Vastauksena käyttäjälle @lefticus
When I saw this feature, I was hoping to be able to do something like this: https://godbolt.org/z/16zz1Y But alas.
1 vastaus 0 uudelleentwiittausta 2 tykkäystä -
Vastauksena käyttäjälle @tloch14
Yeah that could be interesting
0 vastausta 0 uudelleentwiittausta 1 tykkäys -
Tämä twiitti ei ole saatavilla.
-
I like the idea. Unfortunately, that syntax is already used for indicating the underlying type of the enum. Because integral types and enum types are both type identifiers, I suppose integral types could just be considered "valueless enums" in this context.
1 vastaus 0 uudelleentwiittausta 0 tykkäystä
Like what if the base type is a u8, but you're adding so many extended values you want it to be u16? Can you cast from Derived to Base? What happens when Derived is out of Base's possible numbers? I see lots of problems yet to solve with this.
Lataaminen näyttää kestävän hetken.
Twitter saattaa olla ruuhkautunut tai ongelma on muuten hetkellinen. Yritä uudelleen tai käy Twitterin tilasivulla saadaksesi lisätietoja.