4 ms·
> Except orign enum values yields the underlying type and not an enum value False: enum Foo { foo, bar }; auto x = foo|bar; static_assert(std::is
by gpderetta 2y ago
> Except orign enum values yields the underlying type and not an enum value
False:
enum Foo { foo, bar };
auto x = foo|bar;
static_assert(std::is_same_v<decltype(foo), Foo>);
edit: I'm wrong, see below.
- account42 2y agoI meant bitwise operations of enum values and not the values themselves of course. The type of x in your example is int.
- gpderetta 2y agoAh! I meant to write decltype(x). And indeed you are right, it is int. TIL. I had checked on godblot, but of course the typo misled me. In retrospect it makes sense, there is no operator| for enum, it is just calling the int version after implicit conversion.