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:
parent
ee483226e6
commit
87e32bc3fc
1 changed files with 3 additions and 0 deletions
|
|
@ -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 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); }
|
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>
|
template<typename T, template<class,class...> class C, class... Args>
|
||||||
std::ostream& operator<<(std::ostream& os, const C<T,Args...>& objs)
|
std::ostream& operator<<(std::ostream& os, const C<T,Args...>& objs)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue