I have a question about various forms enumand enum class, in particular, to indicate a large number of constants (copied!).
I was wondering if there is a way to declare an enumerated area that is implicitly converted to an integer. To do this, it would be necessary to indicate the addresses of the registers and have access to them with MY_REGISTERS::FOO.
Here are the parameters that I know and have encountered, imagine that there is a function with a signature void do_something(uint32_t bla).
1: enum class
The enum class has scope, but is not implicitly converted to an integer. I consider it important that I do not have to static_castinteger it, so this does not seem to fit correctly.
enum class Foo : uint32_t
{
BAR = 0x0000,
BAZ = 0x0001
};
do_something(Foo::BAR)
2: enum
C , ( ). , :
enum Foo : uint32_t
{
BAR = 0x0000,
BAZ = 0x0001
}
do_something(Foo::BAR)
do_something(BAR)
3: namespaced enum
, , . - ,
namespace Foo
{
enum dontcare : uint32_t
{
BAR = 0x0000,
BAZ = 0x0001
};
}
do_something(Foo::BAR)
do_something(BAR)
4: namespaced static constexpr
, , ( enum) , .
namespace Foo
{
static constexpr uint32_t BAR = 0x0000,
static constexpr uint32_t BAZ = 0x0001
}
do_something(Foo::BAR)
do_something(BAR)
, , , namespaced enum, namespaced constexpr s?