I have a custom data type that in practice can be either float
or double
. On every OS except OSX, I am able to successfully build this C++11 templa
If you have many template functions causing this problem, you can use the following drop-in replacement:
#include
#include
#include
namespace util {
template
auto abs(T value) -> std::enable_if_t::value,
T> { return value; }
template
auto abs(T value) -> std::enable_if_t::value,
T> { return std::fabs(value); }
template
auto abs(T value) -> std::enable_if_t::value,
T> { return std::abs(value); }
template
auto abs(T value) -> std::enable_if_t::value,
T> { return std::labs(value); }
template
auto abs(T value) -> std::enable_if_t::value,
T> { return std::llabs(value); }
template
auto abs(T value) -> std::enable_if_t::value &&
!std::is_floating_point::value &&
!std::is_same::value &&
!std::is_same::value &&
!std::is_same::value,
T> { return std::abs(value); }
} // namespace util
Just replace the std::abs
calls with util::abs
. (Needs c++11
.)