c++: alternative to 'std::is_fundamental'?

c++, c++11, type-traits

Solution

You could use Boost's type traits in C++03 like this:

#include  <boost/type_traits/is_fundamental.hpp>

...

if(boost::is_fundamental<T>::value)
{
    // Treat it as a primitive
}
else
{
    //Treat it otherwise
}

I guess this should work for C++98 as well.

Problem

In a function within a template class, I'm trying to distinguish between primitive types and others. In c++ 11 you can do: ``` if(std::is_fundamental<T>::value) { // Treat it as a primitive } else { //Treat it otherwise } ``` Please correct me if I'm wrong and this is not only in c++ 11. Is there an alternative to this in earlier versions of c++?

Original source