• Paul@feddit.dk
    link
    fedilink
    arrow-up
    1
    ·
    edit-2
    3 months ago

    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).

    • bitcrafter@programming.dev
      link
      fedilink
      arrow-up
      1
      ·
      3 months ago

      Ah. In that case, I look forward to there being a new keyword in C++26 or later that you add to enforce that the enumeration really only does take one of the enumerated values, rather than just being a strongly typed number, since that seems to be the way that the language likes to do things…