1
0
mirror of https://github.com/Kitware/CMake.git synced 2025-10-21 14:40:48 +08:00
Files
CMake/Utilities/std/cm/algorithm
Kitware Robot 1772622772 LICENSE: Replace references to Copyright.txt with LICENSE.rst
```
git grep -lz 'Copyright.txt or https://cmake.org/licensing ' |
  while IFS= read -r -d $'\0' f ; do
    sed -i '/Copyright.txt or https:\/\/cmake.org\/licensing / {
              s/Copyright.txt/LICENSE.rst/
            }' "$f" ; done
```
2025-03-03 10:43:35 -05:00

36 lines
729 B
C++

// -*-c++-*-
// vim: set ft=cpp:
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
file LICENSE.rst or https://cmake.org/licensing for details. */
#pragma once
#include <algorithm> // IWYU pragma: export
#include <cassert>
namespace cm {
#if __cplusplus >= 201703L || defined(_MSVC_LANG) && _MSVC_LANG >= 201703L
using std::clamp;
#else
template <typename T>
T const& clamp(T const& v, T const& lo, T const& hi)
{
assert(!(hi < lo));
return (v < lo) ? lo : (hi < v) ? hi : v;
}
template <typename T, typename Comp>
T const& clamp(T const& v, T const& lo, T const& hi, Comp comp)
{
assert(!comp(hi, lo));
return comp(v, lo) ? lo : comp(hi, v) ? hi : v;
}
#endif
} // namespace cm