Skip to content

Commit fa3e4dc

Browse files
committed
Added EnumFlags helper.
1 parent a8ffbbd commit fa3e4dc

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

include/react/common/Containers.h

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,28 @@
1414

1515
/***************************************/ REACT_IMPL_BEGIN /**************************************/
1616

17+
///////////////////////////////////////////////////////////////////////////////////////////////////
18+
/// BitField
19+
///////////////////////////////////////////////////////////////////////////////////////////////////
20+
template <typename T>
21+
class EnumFlags
22+
{
23+
public:
24+
using FlagsT = typename std::underlying_type<T>::type;
25+
26+
template <T x>
27+
void Set() { flags_ |= 1 << x; }
28+
29+
template <T x>
30+
void Clear() { flags_ &= ~(1 << x); }
31+
32+
template <T x>
33+
bool Test() const { return (flags_ & (1 << x)) != 0; }
34+
35+
private:
36+
FlagsT flags_ = 0;
37+
};
38+
1739
///////////////////////////////////////////////////////////////////////////////////////////////////
1840
/// NodeVector
1941
///////////////////////////////////////////////////////////////////////////////////////////////////

0 commit comments

Comments
 (0)