Use std::clamp with C++17
This commit is contained in:
parent
deee52ce19
commit
ba5ddc4bcb
1 changed files with 4 additions and 0 deletions
|
@ -31,12 +31,16 @@ inline bool chars_less_insensitive(char a, char b) { return tolower(a) < tolower
|
||||||
|
|
||||||
namespace utils {
|
namespace utils {
|
||||||
|
|
||||||
|
#ifdef HAVE_CXX17
|
||||||
|
using std::clamp;
|
||||||
|
#else
|
||||||
// NOTE: remove once we have C++17 support and can use std::clamp
|
// NOTE: remove once we have C++17 support and can use std::clamp
|
||||||
template<typename T>
|
template<typename T>
|
||||||
CONSTEXPR const T& clamp(const T& value, const T& min, const T& max)
|
CONSTEXPR const T& clamp(const T& value, const T& min, const T& max)
|
||||||
{
|
{
|
||||||
return std::max<T>(std::min<T>(value, max), min);
|
return std::max<T>(std::min<T>(value, max), min);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace detail {
|
namespace detail {
|
||||||
/// A struct that exists to implement a generic wrapper for std::find.
|
/// A struct that exists to implement a generic wrapper for std::find.
|
||||||
|
|
Loading…
Add table
Reference in a new issue