|
|
@@ -48,16 +48,16 @@
|
|
|
\
|
|
|
public: \
|
|
|
/* Translate a boolean into a tribool value, will never be Maybe */ \
|
|
|
- TypeName(bool state) : state_(state ? True : False) {} \
|
|
|
- TypeName(Enum state) : state_(state) {} \
|
|
|
+ constexpr TypeName(bool state) : state_(state ? True : False) {} \
|
|
|
+ constexpr TypeName(Enum state) : state_(state) {} \
|
|
|
\
|
|
|
/* Convert to enum for use in switch() statements */ \
|
|
|
- operator Enum() const { return state_; } \
|
|
|
+ constexpr Enum operator*() const { return state_; } \
|
|
|
/* Convert to bool for use in if()/while() statements, requires static_cast otherwise */ \
|
|
|
- explicit operator bool() const { return state_ != False; } \
|
|
|
+ constexpr explicit operator bool() const { return state_ != False; } \
|
|
|
\
|
|
|
/* Inverts the tribool's value if it is already a concrete boolean type */ \
|
|
|
- friend TypeName operator!(TypeName val) { \
|
|
|
+ friend constexpr TypeName operator!(TypeName val) { \
|
|
|
if (val.state_ == Maybe) { \
|
|
|
return Maybe; \
|
|
|
} \
|
|
|
@@ -65,7 +65,7 @@
|
|
|
} \
|
|
|
\
|
|
|
/* Combines two tribools as if performing boolean-OR */ \
|
|
|
- friend TypeName operator|(TypeName lhs, TypeName rhs) { \
|
|
|
+ friend constexpr TypeName operator|(TypeName lhs, TypeName rhs) { \
|
|
|
if (lhs.state_ == True || rhs.state_ == True) { \
|
|
|
return True; \
|
|
|
} \
|
|
|
@@ -76,7 +76,7 @@
|
|
|
} \
|
|
|
\
|
|
|
/* Combines two tribools as if performing boolean-AND */ \
|
|
|
- friend TypeName operator&(TypeName lhs, TypeName rhs) { \
|
|
|
+ friend constexpr TypeName operator&(TypeName lhs, TypeName rhs) { \
|
|
|
if (lhs.state_ == False || rhs.state_ == False) { \
|
|
|
return False; \
|
|
|
} \
|
|
|
@@ -86,16 +86,16 @@
|
|
|
return True; \
|
|
|
} \
|
|
|
\
|
|
|
- TypeName & operator&=(TypeName rhs) { return *this = *this & rhs; } \
|
|
|
- TypeName & operator|=(TypeName rhs) { return *this = *this | rhs; } \
|
|
|
+ constexpr TypeName & operator&=(TypeName rhs) { return *this = *this & rhs; } \
|
|
|
+ constexpr TypeName & operator|=(TypeName rhs) { return *this = *this | rhs; } \
|
|
|
\
|
|
|
- friend auto operator==(TypeName lhs, TypeName::Enum rhs) { \
|
|
|
+ friend constexpr auto operator==(TypeName lhs, TypeName::Enum rhs) { \
|
|
|
return static_cast<int>(lhs.state_) == static_cast<int>(rhs); \
|
|
|
} \
|
|
|
- friend auto operator!=(TypeName lhs, TypeName::Enum rhs) { \
|
|
|
+ friend constexpr auto operator!=(TypeName lhs, TypeName::Enum rhs) { \
|
|
|
return static_cast<int>(lhs.state_) != static_cast<int>(rhs); \
|
|
|
} \
|
|
|
- friend auto operator<=>(TypeName lhs, TypeName rhs) { \
|
|
|
+ friend constexpr auto operator<=>(TypeName lhs, TypeName rhs) { \
|
|
|
return static_cast<int>(lhs.state_) <=> static_cast<int>(rhs.state_); \
|
|
|
} \
|
|
|
}
|