Is there any way in Visual Studio 2012 to restrict function templates to specific types?
This one works in GCC, but MSVC generates error C4519: default template arguments are only allowed on a class template.
#include <type_traits>
template <class float_t, class = typename std::enable_if< std::is_floating_point<float_t>::value >::type>
inline float_t floor(float_t x)
{
float_t result;
//...
return result;
}
A cross compiler solution would be the best. Any alternative?
Normally, you would write this as
template <class float_t>
typename std::enable_if< std::is_floating_point<float_t>::value, float_t>::type
floor(float_x x) {...}
That's how enable_if is intended to be used.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With