18template <UnitLike U, NumericValue T>
19[[nodiscard]]
constexpr UnitValue<U, T> abs(
const UnitValue<U, T>& v)
noexcept {
20 return UnitValue<U, T>{v.v < T{} ?
static_cast<T
>(-v.v) : v.v};
23template <UnitLike U, NumericValue T>
24[[nodiscard]]
constexpr UnitValue<U, T> min(
const UnitValue<U, T>& a,
25 const UnitValue<U, T>& b)
noexcept {
26 return a.v < b.v ? a : b;
29template <UnitLike U, NumericValue T>
30[[nodiscard]]
constexpr UnitValue<U, T> max(
const UnitValue<U, T>& a,
31 const UnitValue<U, T>& b)
noexcept {
32 return a.v < b.v ? b : a;
35template <UnitLike U, NumericValue T>
36[[nodiscard]]
constexpr UnitValue<U, T>
37clamp(
const UnitValue<U, T>& v,
const UnitValue<U, T>& lo,
const UnitValue<U, T>& hi)
noexcept {
45template <MeasureLike M, NumericValue T>
46[[nodiscard]]
constexpr MeasureValue<M, T> abs(
const MeasureValue<M, T>& v)
noexcept {
47 return MeasureValue<M, T>{v.v < T{} ?
static_cast<T
>(-v.v) : v.v};
50template <MeasureLike M, NumericValue T>
51[[nodiscard]]
constexpr MeasureValue<M, T> min(
const MeasureValue<M, T>& a,
52 const MeasureValue<M, T>& b)
noexcept {
53 return a.v < b.v ? a : b;
56template <MeasureLike M, NumericValue T>
57[[nodiscard]]
constexpr MeasureValue<M, T> max(
const MeasureValue<M, T>& a,
58 const MeasureValue<M, T>& b)
noexcept {
59 return a.v < b.v ? b : a;
62template <MeasureLike M, NumericValue T>
63[[nodiscard]]
constexpr MeasureValue<M, T> clamp(
const MeasureValue<M, T>& v,
64 const MeasureValue<M, T>& lo,
65 const MeasureValue<M, T>& hi)
noexcept {
75template <UnitLike U, NumericValue T>
80template <MeasureLike M, NumericValue T>
81[[nodiscard]]
constexpr MeasureValue<M, T> midpoint(
const MeasureRangeValue<M, T>& r)
noexcept {
82 return MeasureValue<M, T>{
static_cast<T
>((r.min().v + r.max().v) / T{2})};
Closed/open interval over a UnitValue<U,T>.
Definition range.hpp:45
constexpr UnitValue< U, T > midpoint(const UnitRangeValue< U, T > &r) noexcept
Midpoint of a range's bounds.
Definition math.hpp:76
MeasureValue<M,T>: a UnitValue tagged with an additional semantic measure.
UnitRangeValue and MeasureRangeValue — closed/open intervals of dimensional values.
A value paired at the type level with a unit tag.
Definition unit.hpp:36
Concepts and helper accessors that drive the static side of dimval.
UnitValue<U,T>: a strongly-typed value carrying a compile-time unit tag.