all: cleanups
This commit is contained in:
+11
-11
@@ -209,24 +209,24 @@ public:
|
||||
static_assert(TOther != 0 && TOther != 1);
|
||||
enum value_type : underlying_type { False = 0, True = 1, Other = TOther };
|
||||
// constructors
|
||||
forceinline TriBool() noexcept = default;
|
||||
forceinline constexpr TriBool() noexcept = default;
|
||||
forceinline ~TriBool() noexcept = default;
|
||||
constexpr TriBool(value_type x) noexcept : value(x) {}
|
||||
constexpr TriBool(promoted_type x) noexcept : value(x == 0 ? False : (x == 1 ? True : Other)) {}
|
||||
// access
|
||||
value_type getValue() const noexcept { return value; }
|
||||
constexpr value_type getValue() const noexcept { return value; }
|
||||
// checks for > 0, so TOther determines if Other is false (the default) or true
|
||||
explicit operator bool() const noexcept { return value > False; }
|
||||
explicit constexpr operator bool() const noexcept { return value > False; }
|
||||
// query; this is NOT the same as operator bool()
|
||||
bool isStrictFalse() const noexcept { return value == False; }
|
||||
bool isStrictTrue() const noexcept { return value == True; }
|
||||
bool isStrictBool() const noexcept { return value == False || value == True; }
|
||||
bool isOther() const noexcept { return value != False && value != True; }
|
||||
constexpr bool isStrictFalse() const noexcept { return value == False; }
|
||||
constexpr bool isStrictTrue() const noexcept { return value == True; }
|
||||
constexpr bool isStrictBool() const noexcept { return value == False || value == True; }
|
||||
constexpr bool isOther() const noexcept { return value != False && value != True; }
|
||||
// "other" can mean many things, depending on usage context, so provide some alternative names:
|
||||
// forceinline bool isDefault() const noexcept { return isOther(); } // might be misleading
|
||||
forceinline bool isIndeterminate() const noexcept { return isOther(); }
|
||||
forceinline bool isUndecided() const noexcept { return isOther(); }
|
||||
// forceinline bool isUnset() const noexcept { return isOther(); } // might be misleading
|
||||
// constexpr bool isDefault() const noexcept { return isOther(); } // might be misleading
|
||||
constexpr bool isIndeterminate() const noexcept { return isOther(); }
|
||||
constexpr bool isUndecided() const noexcept { return isOther(); }
|
||||
// constexpr bool isUnset() const noexcept { return isOther(); } // might be misleading
|
||||
constexpr bool operator==(TriBool other) const noexcept { return value == other.value; }
|
||||
constexpr bool operator==(value_type other) const noexcept { return value == other; }
|
||||
constexpr bool operator==(promoted_type other) const noexcept { return value == other; }
|
||||
|
||||
Reference in New Issue
Block a user