The bitmask type bitmask can be written:
enum bitmask : int_type {
V0 = 1 << 0, V1 = 1 << 1, V2 = 1 << 2, V3 = 1 << 3, …
};
inline constexpr bitmask C0(V0);
inline constexpr bitmask C1(V1);
inline constexpr bitmask C2(V2);
inline constexpr bitmask C3(V3);
⋮
constexpr bitmask operator&(bitmask X, bitmask Y) {
return static_cast<bitmask>(
static_cast<int_type>(X) & static_cast<int_type>(Y));
}
constexpr bitmask operator|(bitmask X, bitmask Y) {
return static_cast<bitmask>(
static_cast<int_type>(X) | static_cast<int_type>(Y));
}
constexpr bitmask operator^(bitmask X, bitmask Y) {
return static_cast<bitmask>(
static_cast<int_type>(X) ^ static_cast<int_type>(Y));
}
constexpr bitmask operator~(bitmask X) {
return static_cast<bitmask>(~static_cast<int_type>(X));
}
bitmask& operator&=(bitmask& X, bitmask Y) {
X = X & Y; return X;
}
bitmask& operator|=(bitmask& X, bitmask Y) {
X = X | Y; return X;
}
bitmask& operator^=(bitmask& X, bitmask Y) {
X = X ^ Y; return X;
}