Boost logo

Boost Users :

Subject: Re: [Boost-users] error with static assert and floating-point detection
From: John Maddock (boost.regex_at_[hidden])
Date: 2014-03-11 12:42:25


> 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.


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net