|
|
|
|
|
by modulared
774 days ago
|
|
> Enums produce values. Tag-only unions 'produce' types (without values). Source? Is this something that is widely accepted, or just how you think enums should be defined. My understanding is you are saying (using c++ as an example since it has both types) an `enum` is a "true" enum, while an `enum class` somehow isn't? |
|
To which language?
> `enum` is a "true" enum, while an `enum class` somehow isn't?
No. Enums are used in both cases. The difference there is in the types the enums are applied to. In one case, a basic integer-based type. In the other, a class.
This differs from Rust. Rust does not use enums. It relies on the type itself to carry all the information. C++ enum classes could have done the same, so it is not clear why they chose to use enums, but perhaps for the sake of familiarity or backwards compatibility with the regular enum directive?