Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

5 Commits

Repository files navigation

cpp17-enum-flag

Enable bitwise operators on scoped enums.

Library compiles with no warnings (-std=c++17 -Wall -Wshadow -Wextra -Wnon-virtual-dtor -pedantic) on Clang 14.

Example usage

enumclassTestEnum
{
Baz = 1 << 0,
Fou = 1 << 1,
Moo = 1 << 2,
Foo = 1 << 3,
Bar = 1 << 4,
};
template <>
structzsl::EnumFlags<TestEnum>
{
staticconstexprbool is_flags = true;
};
// ...automain() -> int
{
TestEnum e{TestEnum::Baz};
auto b = zsl::EnumIsSet(e & TestEnum::Baz);
std::cout << (b ? "true" : "false");
e = TestEnum::Foo | TestEnum::Baz;
return0;
}

About

Enable bitwise operators on scoped enums.

Topics

Resources

Stars

14 stars

Watchers

1 watching

Forks

Contributors

Languages