@@ -10,7 +10,7 @@ The only drawback to type safety is you cannot treat variables of *enum class*
1010types as sets of flags. That is because * enum classes* do not cast to integers
1111and there are no bitwise operators overloads defined for them.
1212
13- This project brings a ` flags ` class template which:
13+ This library brings a ` flags ` class template which:
1414* does not convert to or from integer types;
1515* does implicitly convert from enum it was instantiated by;
1616* does not convert to that enum;
@@ -19,24 +19,31 @@ This project brings a `flags` class template which:
1919* explicitly converts to bool (which allows to use it in boolean contexts, like
2020 in branching or loop conditions);
2121* provides access to the underlying integer through member functions;
22- * instantiates only for enum classes .
22+ * instantiates only for enums it was explicitly enabled for .
2323
2424## Usage
2525``` c++
2626enum class MyEnum { Value1 = 1 << 0, Value2 = 1 << 1 };
27- using MyEnums = flags<MyEnum >; // actually this line is not necessary
2827
29- auto mask = Value1 | Value2; // set flags Value1 and Value 2
30- if (mask & Value2) { // if Value2 flag is set
31- doSomething();
28+ namespace flags {
29+ template <> struct is_flags<MyEnum > : std::true_type {};
30+ }
31+ // or just use macro:
32+ // ALLOW_FLAGS_FOR_ENUM(MyEnum)
33+
34+ using MyEnums = flags::flags<MyEnum >;
35+
36+ MyEnums mask1 = Value1 | Value2; // set flags Value1 and Value 2
37+ if (mask1 & Value2) { // if Value2 flag is set
38+ doSomething();
3239}
3340```
3441
3542## Description
3643``` c++
3744template <class E> class flags;
3845```
39- where ` E ` is an enum class .
46+ where ` E ` is an enum.
4047
4148### Member types
4249Member type |Definition |Notes
0 commit comments