Skip to content

Instantly share code, notes, and snippets.

@OlivierLDff
Last active January 3, 2020 15:06
Show Gist options
  • Save OlivierLDff/c266ecb67cb97f59ead6f7fc853eff29 to your computer and use it in GitHub Desktop.
Save OlivierLDff/c266ecb67cb97f59ead6f7fc853eff29 to your computer and use it in GitHub Desktop.
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