Commit 0bf96571 authored by Kenton Varda's avatar Kenton Varda

Allow `kj::Absolute<T>` to be initialized to `kj::maxValue`.

`kj::Quantity<T>` already supported this. I copied from it.
parent c786c444
......@@ -423,6 +423,13 @@ class Absolute {
// units, which is actually totally logical and kind of neat.
public:
inline constexpr Absolute(MaxValue_): value(maxValue) {}
inline constexpr Absolute(MinValue_): value(minValue) {}
// Allow initialization from maxValue and minValue.
// TODO(msvc): decltype(maxValue) and decltype(minValue) deduce unknown-type for these function
// parameters, causing the compiler to complain of a duplicate constructor definition, so we
// specify MaxValue_ and MinValue_ types explicitly.
inline constexpr Absolute operator+(const T& other) const { return Absolute(value + other); }
inline constexpr Absolute operator-(const T& other) const { return Absolute(value - other); }
inline constexpr T operator-(const Absolute& other) const { return value - other.value; }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment