Changeset 11096 for code/trunk/src/libraries/util/tribool.h
- Timestamp:
- Jan 25, 2016, 9:33:11 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk/src/libraries/util/tribool.h
r8729 r11096 10 10 // so that (dontcare == dontcare). 11 11 // Also removed all logic operators except for == and != 12 // Added C++11 constexpr 12 13 13 14 … … 22 23 * The type of the 'dontcare' keyword. 23 24 */ 24 struct dontcare_keyword_t { 25 struct dontcare_keyword_t {}; 25 26 26 27 /** 27 28 * \brief Keyword for the dontcare tribool value 28 29 */ 29 const dontcare_keyword_t dontcare = dontcare_keyword_t();30 constexpr dontcare_keyword_t dontcare = dontcare_keyword_t(); 30 31 31 32 /** … … 43 44 * \throws nothrow 44 45 */ 45 tribool() : value(false_value) {}46 constexpr tribool() : value(false_value) {} 46 47 47 48 /** … … 51 52 * \throws nothrow 52 53 */ 53 tribool(bool value) : value(value? true_value : false_value) {}54 constexpr tribool(bool value) : value(value? true_value : false_value) {} 54 55 55 56 /** … … 58 59 * \throws nothrow 59 60 */ 60 tribool(dontcare_keyword_t) : value(dontcare_value) {}61 constexpr tribool(dontcare_keyword_t) : value(dontcare_value) {} 61 62 62 63 /** … … 66 67 * \throws nothrow 67 68 */ 68 inline bool operator==(tribool y)69 constexpr bool operator==(tribool y) const 69 70 { 70 71 return (this->value == y.value); … … 74 75 * \overload 75 76 */ 76 inline bool operator==(bool y){ return (*this) == tribool(y); }77 constexpr bool operator==(bool y) const { return (*this) == tribool(y); } 77 78 78 79 /** 79 80 * \overload 80 81 */ 81 inline bool operator==(dontcare_keyword_t)82 constexpr bool operator==(dontcare_keyword_t) const 82 83 { return tribool(dontcare) == (*this); } 83 84 … … 88 89 * \throws nothrow 89 90 */ 90 inline bool operator!=(tribool y)91 constexpr bool operator!=(tribool y) const 91 92 { 92 93 return !((*this) == y); … … 96 97 * \overload 97 98 */ 98 inline bool operator!=(bool y){ return (*this) != tribool(y); }99 constexpr bool operator!=(bool y) const { return (*this) != tribool(y); } 99 100 100 101 /** 101 102 * \overload 102 103 */ 103 inline bool operator!=(dontcare_keyword_t)104 constexpr bool operator!=(dontcare_keyword_t) const 104 105 { return (*this) != tribool(dontcare); } 105 106 … … 114 115 * \overload 115 116 */ 116 inlinebool operator==(bool x, tribool y) { return tribool(x) == y; }117 constexpr bool operator==(bool x, tribool y) { return tribool(x) == y; } 117 118 118 119 /** 119 120 * \overload 120 121 */ 121 inlinebool operator==(dontcare_keyword_t, tribool x)122 constexpr bool operator==(dontcare_keyword_t, tribool x) 122 123 { return tribool(dontcare) == x; } 123 124 … … 125 126 * \overload 126 127 */ 127 inlinebool operator!=(bool x, tribool y) { return tribool(x) != y; }128 constexpr bool operator!=(bool x, tribool y) { return tribool(x) != y; } 128 129 129 130 /** 130 131 * \overload 131 132 */ 132 inlinebool operator!=(dontcare_keyword_t, tribool x)133 constexpr bool operator!=(dontcare_keyword_t, tribool x) 133 134 { return tribool(dontcare) != x; } 134 135
Note: See TracChangeset
for help on using the changeset viewer.