You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I would love to bitshift an integral value by an enum value.
Example usage:
Creating a flag enum based on an existing enum:
enum class A {
X = 0,
Y = 1,
Z = 2
};
enum class AFlags {
XF = 1 << A::X,
YF = 1 << A::Y,
ZF = 1 << A::Z
};
General Bitshifting by an enum value:
A a = A::Y;
auto flag = 1 << a;
Currently i have that implemented by the C++23 code:
template<typename E>
requires std::is_enum_v<E>
constexpr auto operator<<(const std::integral auto& a, const E& b) {
return a << std::to_underlying(b);
}
I suggest implementing a bitshift in both directions by an enum. Maybe you want to add bitshifting an enum by an integral as well, and maybe even an enum by an enum.
The text was updated successfully, but these errors were encountered:
I would love to bitshift an integral value by an enum value.
Example usage:
Creating a flag enum based on an existing enum:
General Bitshifting by an enum value:
Currently i have that implemented by the C++23 code:
I suggest implementing a bitshift in both directions by an enum. Maybe you want to add bitshifting an enum by an integral as well, and maybe even an enum by an enum.
The text was updated successfully, but these errors were encountered: