MCPcopy Create free account
hub / github.com/cel-expr/cel-cpp / UintCompareVisitor

Class UintCompareVisitor

internal/number.h:127–146  ·  view source on GitHub ↗

Implement generic numeric comparison against uint value. Delegates to double comparison if either variable is double.

Source from the content-addressed store, hash-verified

125// Implement generic numeric comparison against uint value.
126// Delegates to double comparison if either variable is double.
127struct 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.

Callers 2

operator()Method · 0.85
operator()Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected