Sometimes it is useful to be able to query for all the members of an
`enum_set`, rather than just add, remove, and query for membership. (The
patch following this one makes use of this in the auth. sub-system).
We use the bitset iterator in Seastar to help with the implementation.
`super_enum::valid_is_valid_sequence` determines if the numeric index
corresponding to an enumeration value is valid. This is important,
because it is undefined behavior to cast an invalid index into an
enumeration value.
This function is used to check the validity of the `enum_set` mask when
an `enum_set` is constructed in `enum_set::from_mask`. If the mask has
set bits that correspond to invalid enumeration indicies, then we throw
`bad_enum_set_mask`.
This:
set_if<item>(cond);
is a more efficient version of:
if (cond) {
set<item>();
}
The implementation can leverage internal representation to avoid
branching and thus make the operation cheaper.
Allows to take full advantage of compile-time information.
Examples:
enum class x { A, B, C };
using my_enum = super_enum<x, x::A, x::B, x::C>;
using my_enumset = enum_set<my_enum>;
static_assert(my_enumset::frozen<x::A, x::B>::contains<x::A>(),
"it should...");
assert(my_enumset::frozen<x::A, x::B>::contains(x::A));