mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-13 19:49:51 +01:00
14 lines
288 B
C++
14 lines
288 B
C++
|
#pragma once
|
||
|
|
||
|
namespace AB_NAMESPACE {
|
||
|
|
||
|
// http://en.cppreference.com/w/cpp/algorithm/clamp
|
||
|
|
||
|
template <class T>
|
||
|
constexpr const T &clamp(const T &v, const T &lo, const T &hi)
|
||
|
{
|
||
|
return assert(!(hi < lo)), (v < lo) ? lo : (hi < v) ? hi : v;
|
||
|
}
|
||
|
|
||
|
} // namespace AB_NAMESPACE
|