maths: fix the ordering of limit
This commit is contained in:
parent
8487f700f6
commit
75d69bf9df
@ -182,5 +182,7 @@ template int sign (int);
|
|||||||
// so it's easier to instantiate early and check for broken code at library
|
// so it's easier to instantiate early and check for broken code at library
|
||||||
// build time.
|
// build time.
|
||||||
|
|
||||||
|
template float limit (float, float, float);
|
||||||
|
|
||||||
template float smoothstep (float, float, float);
|
template float smoothstep (float, float, float);
|
||||||
template double smoothstep (double, double, double);
|
template double smoothstep (double, double, double);
|
||||||
|
10
maths.hpp
10
maths.hpp
@ -276,10 +276,18 @@ max [[gnu::pure]] (const T a, const U b, Args ...args)
|
|||||||
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
// Limiting functions
|
||||||
|
|
||||||
|
// min/max clamping
|
||||||
template <typename T, typename U, typename V>
|
template <typename T, typename U, typename V>
|
||||||
T
|
T
|
||||||
limit [[gnu::pure]] (const T val, const U hi, const V lo)
|
limit [[gnu::pure]] (const T val, const U lo, const V hi)
|
||||||
{
|
{
|
||||||
|
CHECK_LE(
|
||||||
|
decltype (lo+hi) (lo),
|
||||||
|
decltype (hi+lo) (hi)
|
||||||
|
);
|
||||||
|
|
||||||
return val > hi ? hi:
|
return val > hi ? hi:
|
||||||
val < lo ? lo:
|
val < lo ? lo:
|
||||||
val;
|
val;
|
||||||
|
Loading…
Reference in New Issue
Block a user