|
template<class T , class U > |
constexpr T | SafeAdd (T lhs, U rhs) |
| returns lhs+rhs, clamping return values that would roll over to the min/max values of lhs. More...
|
|
template<class T , class U = int> |
constexpr T & | Increase (T &obj, U diff=1) |
| roll over safe variant of ++some_value; More...
|
|
template<class T , class U = int> |
constexpr T & | Decrease (T &obj, U diff=1) |
| roll over safe variant of –some_value; More...
|
|
template<class T , class M , class U = int> |
constexpr decltype(auto) | DecreaseMember (T &obj, M member, U diff=1) |
| Identical to the other decrease function. More...
|
|
template<class T , class S > |
auto | mod (T v, S m) -> decltype(v % m) |
| Returns the canonical representation of [v] considered as element of Z/mZ, regardless of any silly features C++ board thought that would be better than actual math when using non-positive input. More...
|
|
template<class T , class S > |
auto | min (T l, S r) |
|
template<class T , class S > |
auto | max (T l, S r) |
|
template<class V , class L , class U > |
auto | clamp (V value, L lower, U upper) |
| Returns: More...
|
|
template<class T > |
T | round (float val) |
| Rounds a numeric value. More...
|
|
template<class T , class M , class U = int>
constexpr decltype(auto) CsMath::DecreaseMember |
( |
T & |
obj, |
|
|
M |
member, |
|
|
U |
diff = 1 |
|
) |
| |
|
inlineconstexpr |
Identical to the other decrease function.
Use this variation if you get errors like: 'cannot bind packed field to ...&' or 'taking address of packed member ... may result in an unaligned pointer value'.
template<class T , class S >
auto CsMath::mod |
( |
T |
v, |
|
|
S |
m |
|
) |
| -> decltype(v % m) |
Returns the canonical representation of [v] considered as element of Z/mZ, regardless of any silly features C++ board thought that would be better than actual math when using non-positive input.
Return value is always in the half open interval [0,m). For any values v,n and m, mod(v,m) == mod(v+ n*m, m) holds.
Template implemented for integral types.