Implement generic numeric comparison against uint value. Delegates to double comparison if either variable is double.
| 125 | // Implement generic numeric comparison against uint value. |
| 126 | // Delegates to double comparison if either variable is double. |
| 127 | struct UintCompareVisitor { |
| 128 | constexpr explicit UintCompareVisitor(uint64_t v) : v(v) {} |
| 129 | |
| 130 | constexpr ComparisonResult operator()(double other) const { |
| 131 | return Invert(DoubleCompareVisitor(other)(v)); |
| 132 | } |
| 133 | |
| 134 | constexpr ComparisonResult operator()(uint64_t other) const { |
| 135 | return Compare(v, other); |
| 136 | } |
| 137 | |
| 138 | constexpr ComparisonResult operator()(int64_t other) const { |
| 139 | if (v > kUintToIntMax || other < 0) { |
| 140 | return ComparisonResult::kGreater; |
| 141 | } else { |
| 142 | return Compare(v, static_cast<uint64_t>(other)); |
| 143 | } |
| 144 | } |
| 145 | uint64_t v; |
| 146 | }; |
| 147 | |
| 148 | // Implement generic numeric comparison against int value. |
| 149 | // Delegates to uint / double if either value is uint / double. |
no outgoing calls
no test coverage detected