this post was submitted on 05 Aug 2024
14 points (93.8% liked)
C++
1760 readers
1 users here now
The center for all discussion and news regarding C++.
Rules
- Respect instance rules.
- Don't be a jerk.
- Please keep all posts related to C++.
founded 1 year ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
Could someone explain to me what the value is in making it really easy to initialize an enum class with a value that is not one of the enumerated values?
Good question. My response would be: only where it is not used as an enum. The example in the article is one example (although I've never seen that idiom in the wild) or for doing things like bitfields (the opposite of the
to_underlying
section).