error with static assert and floating-point detection
Hello, I try to use Boost Static Assert to define a template parameter only for double & floats. I use the call BOOST_STATIC_ASSERT( !boost::is_integral<T>::value ) I get in a class the error: error: no member named 'is_integral' in namespace 'boost' BOOST_STATIC_ASSERT( !boost::is_integral<T>::value ) My question is, how can I check the template parameter so that only floating-point types are allowed? How can I avoid the error? Thanks Phil
I try to use Boost Static Assert to define a template parameter only for double & floats. I use the call BOOST_STATIC_ASSERT( !boost::is_integral<T>::value )
I get in a class the error: error: no member named 'is_integral' in namespace 'boost' BOOST_STATIC_ASSERT( !boost::is_integral<T>::value )
My question is, how can I check the template parameter so that only floating-point types are allowed? How can I avoid the error?
Did you #include <boost/type_traits/is_integral.hpp> ? If you wish to restrict the function to floating point types you may also which to use enable_if: template <class T> typename boost::enable_if<is_floating_point<T>, return-type-for-function>::type my_function(T val) { // body here. } HTH, John.
participants (2)
-
John Maddock
-
Philipp Kraus