2011/1/25 Joachim Faulhaber
2011/1/25 Kraus Philipp
: Hello,
I have written a template class and I would like tot "assert the type". My class should only use floating point types like double or float. Can I do this check with BOOST_STATIC_ASSERT or anything else? The class need not to
E.g. #include
#include template<class Type> class real_holder { public: real_holder(Type val): _value(val) { BOOST_STATIC_ASSERT((is_floating_point<Type>::value)); } private: Type _value; };
... { real_holder<double> rh_d(1.0); //OK. real_holder<int> rh_i(1); // compiletime error: //boost::STATIC_ASSERTION_FAILURE<x> }
use a "countable type" (math: in N).
may be you need a different trait depending on the exact specification of your type.
You could use
#include