Last active
September 2, 2018 14:40
-
-
Save kazeto/3ed459bd904a1d41ca101d75d89dedbe to your computer and use it in GitHub Desktop.
Boolean to be automatically initialized to false.
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
class boolean_t | |
{ | |
public: | |
inline boolean_t(bool b = false) : m_bool(b) {} | |
inline boolean_t(const boolean_t&) = default; | |
inline explicit operator bool() const noexcept { return m_bool; } | |
inline bool operator!() const noexcept { return !m_bool; } | |
inline boolean_t& operator=(const boolean_t&) = default; | |
inline boolean_t& operator=(bool b) noexcept { m_bool = b; return *this; } | |
inline void set(bool b) noexcept { m_bool = b; } | |
inline void negate() noexcept { m_bool = not m_bool; } | |
private: | |
bool m_bool; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment