mirror-chatterino2/src/util/Clamp.hpp

14 lines
271 B
C++
Raw Normal View History

#pragma once
2019-10-07 15:46:08 +02:00
namespace chatterino {
// 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;
}
2019-10-07 15:46:08 +02:00
} // namespace chatterino