#pragma once #include #include #undef abs #undef max #undef min namespace std { template T max(T a, T b) { return a < b ? b : a; } template T min(T a, T b) { return a < b ? a : b; } template T abs(T a) { return a < 0 ? -a : a; } #define UNARY(fn) \ template \ typename std::enable_if::value, T>::type \ fn(T a) { return static_cast(::fn(static_cast(a))); } #define BINARY(fn) \ template \ typename std::enable_if::value, T>::type \ fn(T a, T b) { return static_cast(::fn(static_cast(a), static_cast(b))); } UNARY(floor) UNARY(ceil) UNARY(exp) UNARY(log) UNARY(log10) UNARY(sqrt) UNARY(sin) UNARY(cos) UNARY(tan) UNARY(asin) UNARY(acos) UNARY(atan) UNARY(sinh) UNARY(cosh) UNARY(tanh) UNARY(round) BINARY(fmod) BINARY(pow) BINARY(atan2) #undef UNARY #undef BINARY } // namespace std