enum-flags

Bit flags for C++11 scoped enums


Project maintained by grisumbras Hosted on GitHub Pages — Theme by mattgraham

enum-flags is a C++ library that allows you to convert scoped enums into bit flags.
You can use it as simple as this:

#include <flags/flags.hpp>

enum class MyEnum { Value1 = 1 , Value2 = 2 };
ALLOW_FLAGS_FOR_ENUM(MyEnum)

int main() {
  auto mask = MyEnum::Value1 | MyEnum::Value2;
  if (mask & MyEnum::Value2) {
    // do something
  }
  return 0;
}

Documentation