all: cleanups

This commit is contained in:
Markus F.X.J. Oberhumer
2023-08-16 01:06:52 +02:00
parent a9ac4b5e23
commit 394cd77bec
15 changed files with 49 additions and 43 deletions
+11 -11
View File
@@ -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; }