Re: enums that are really just sets of constants




On 19 April 2017 at 09:37, Murray Cumming <murrayc murrayc com> wrote:
However, some of the C enums that we wrap are actually meant to be
integer constants, so it seems that we cannot and should not use "enum
class" for these. So I wonder what is the most "modern C++" way to do
this while keeping the new-style syntax. Here are two possibilities:

1. Use old-style enums inside a class:
2. Use constexpr int constants inside a class:


FWIW, I try to avoid using classes where I don't actually need them (though of course all bets are off where templates come into play), so I would also suggest putting such constants in a namespace, instead of a class. I'm not sure how popular that viewpoint is, but fwiw, a quick search did find some other people on Stack Overflow favouring it.


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]