Added sureAbs() template so that we are sure to not cast a double to an int using ::abs() instead of std::abs().

This commit is contained in:
Jérôme 2019-04-01 16:18:34 +02:00
parent ee483226e6
commit 87e32bc3fc

View file

@ -14,6 +14,9 @@
template<typename T, typename T2> auto min(const T & a, const T2 & b) -> decltype(a | b) { return (a < b) ? T(a) : T(b); }
template<typename T, typename T2> 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<typename T> T sureAbs(const T & x) { return (x < T(0)) ? -x : x; }
template<typename T, template<class,class...> class C, class... Args>
std::ostream& operator<<(std::ostream& os, const C<T,Args...>& objs)
{