Add geom::make_min & make_max
This commit is contained in:
parent
e8a5ecfa3b
commit
afbf49950f
1 changed files with 22 additions and 0 deletions
|
|
@ -171,4 +171,26 @@ namespace psemek::geom
|
||||||
return (x / y) + ((x % y) == 0 ? 0 : 1);
|
return (x / y) + ((x % y) == 0 ? 0 : 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
bool make_min(T & target, T const & source)
|
||||||
|
{
|
||||||
|
if (target > source)
|
||||||
|
{
|
||||||
|
target = source;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
bool make_max(T & target, T const & source)
|
||||||
|
{
|
||||||
|
if (target < source)
|
||||||
|
{
|
||||||
|
target = source;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue