(no title)
x1f604 | 2 years ago
┌─/usr/include/c++/12/bits/stl_algo.h──────────────────────────────────────────────────────────────────────────────────────
│ 3617 \* @pre `_Tp` is LessThanComparable and `(__hi < __lo)` is false.
│ 3618 \*/
│ 3619 template<typename _Tp>
│ 3620 constexpr const _Tp&
│ 3621 clamp(const _Tp& __val, const _Tp& __lo, const _Tp& __hi)
│ 3622 {
│ 3623 __glibcxx_assert(!(__hi < __lo));
│ > 3624 return std::min(std::max(__val, __lo), __hi);
│ 3625 }
│ 3626
cmovq|2 years ago
cornstalks|2 years ago
> 2 Preconditions: `bool(comp(proj(hi), proj(lo)))` is false. For the first form, type `T` meets the Cpp17LessThanComparable requirements (Table 26).
> 3 Returns: `lo` if `bool(comp(proj(v), proj(lo)))` is true, `hi` if `bool(comp(proj(hi), proj(v)))` is true, otherwise `v`.
> 4 [Note: If NaN is avoided, `T` can be a floating-point type. — end note]
From Table 26:
> `<` is a strict weak ordering relation (25.8)
x1f604|2 years ago