Last active
January 3, 2020 15:06
-
-
Save OlivierLDff/c266ecb67cb97f59ead6f7fc853eff29 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
template <typename T> | |
class BitField | |
{ | |
T _flags = 0; | |
public: | |
constexpr bool empty() const { return _flags == 0; } | |
constexpr bool isFlagPresent(const T flag) const { return _flags & T(1 << flag); } | |
constexpr void setFlag(const T flag) { _flags |= T(1 << flag); } | |
constexpr void clearFlag(const T flag) { _flags &= ~T(1 << flag); } | |
constexpr void clear() { _flags = 0; } | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment