Type-safe bitmask and arithmetic operators for enum types.
stlab::enum-ops
provides opt-in operator overloads for enum types, enabling:
- Bitmask operators:
~ | & ^ |= &= ^=
- Shift operators:
<< >> <<= >>=
- Arithmetic operators:
+ - * / % += -= *= /=
and increment/decrement - Comparisons with
0
and logical!
for convenience
Opt-in is done by declaring one or both of:
auto stlab_enable_bitmask_enum(E) -> std::true_type;
auto stlab_enable_arithmetic_enum(E) -> std::true_type;
cmake --preset=test
cmake --build --preset=test
ctest --preset=test
Examples live under examples/
and are built with the test preset:
cmake --build --preset=test --target enum_ops_example
./build/test/examples/enum_ops_example
The simplest way to use stlab::enum-ops
in your project is to add it as a dependency via CPM.
CPMAddPackage("gh:stlab/[email protected]")
Generate Doxygen docs:
cmake --preset=docs
cmake --build --preset=docs --target docs
Distributed under the Boost Software License, Version 1.0. See LICENSE
.