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

Class DoubleCompareVisitor

internal/number.h:96–123  ·  view source on GitHub ↗

Implement generic numeric comparison against double value.

Source from the content-addressed store, hash-verified

94
95// Implement generic numeric comparison against double value.
96struct DoubleCompareVisitor {
97 constexpr explicit DoubleCompareVisitor(double v) : v(v) {}
98
99 constexpr ComparisonResult operator()(double other) const {
100 return DoubleCompare(v, other);
101 }
102
103 constexpr ComparisonResult operator()(uint64_t other) const {
104 if (v > kDoubleToUintMax) {
105 return ComparisonResult::kGreater;
106 } else if (v < 0) {
107 return ComparisonResult::kLesser;
108 } else {
109 return DoubleCompare(v, static_cast<double>(other));
110 }
111 }
112
113 constexpr ComparisonResult operator()(int64_t other) const {
114 if (v > kDoubleToIntMax) {
115 return ComparisonResult::kGreater;
116 } else if (v < kDoubleToIntMin) {
117 return ComparisonResult::kLesser;
118 } else {
119 return DoubleCompare(v, static_cast<double>(other));
120 }
121 }
122 double v;
123};
124
125// Implement generic numeric comparison against uint value.
126// Delegates to double comparison if either variable is double.

Callers 3

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

Calls

no outgoing calls

Tested by

no test coverage detected