diff --git a/utils.hpp b/utils.hpp index 14088ab..376a6b4 100644 --- a/utils.hpp +++ b/utils.hpp @@ -14,6 +14,9 @@ template auto min(const T & a, const T2 & b) -> decltype(a | b) { return (a < b) ? T(a) : T(b); } template auto max(const T & a, const T2 & b) -> decltype(a | b) { return (a < b) ? T(b) : T(a); } +/// To be sure that floating point numbers won't be casted to integers in ::abs()... +template T sureAbs(const T & x) { return (x < T(0)) ? -x : x; } + template class C, class... Args> std::ostream& operator<<(std::ostream& os, const C& objs) {