#ifndef INCLUDE_NCURSES_ENUMS_HPP_ #define INCLUDE_NCURSES_ENUMS_HPP_ extern "C" { #include } #include namespace NCURSES_CPP_NAMESPACE { struct ok_type { NCURSES_CPP_CONSTEXPR_INLINE operator bool() const { return true; } }; NCURSES_CPP_CONSTEXPR_INLINE const ok_type ok; struct err_type { NCURSES_CPP_CONSTEXPR_INLINE operator bool() const { return false; } }; NCURSES_CPP_CONSTEXPR_INLINE const err_type err; class result_type { public: NCURSES_CPP_CONSTEXPR result_type(int code) noexcept : result_(code == OK ? true : false) {} NCURSES_CPP_CONSTEXPR_INLINE operator bool() const { return result_; } NCURSES_CPP_CONSTEXPR_INLINE bool operator==(const result_type &rhs) const { return result_ == rhs.result_; } NCURSES_CPP_CONSTEXPR_INLINE bool operator!=(const result_type &rhs) const { return result_ != rhs.result_; } NCURSES_CPP_CONSTEXPR_INLINE bool operator==(const ok_type &rhs) const { return result_; } NCURSES_CPP_CONSTEXPR_INLINE bool operator==(const err_type &rhs) const { return !result_; } private: bool result_; }; NCURSES_CPP_CONSTEXPR bool operator==(const ok_type &ok, const result_type &result) noexcept { return result == ok; } NCURSES_CPP_CONSTEXPR bool operator!=(const ok_type &ok, const result_type &result) noexcept { return result != ok; } NCURSES_CPP_CONSTEXPR bool operator==(const err_type &err, const result_type &result) noexcept { return result == err; } NCURSES_CPP_CONSTEXPR bool operator!=(const err_type &err, const result_type &result) noexcept { return result != err; } } // namespace NCURSES_CPP_NAMESPACE #endif // INCLUDE_NCURSES_ENUMS_HPP_