Can I determine if a pointer is an integral type using type properties?

Using type properties, I can find out if the type is an integral or a pointer (or more). Is it also possible to find out if the passed pointer passed an integral type (int, float , char), and not an object?

EDIT: In addition to Armen, answer if someone uses the LOKI library instead of Boost, the remove pointer functionality is similar to TypeTraits::PointeeType

+4
source share
2 answers
 boost::is_pointer<T>::value && boost::is_integral<boost::remove_pointer<T>::type>::value 

Btw float not an integer. You will is_arithmetic need is_arithmetic

+4
source
 template <typename T> struct IsPointerToInt { static const bool value = false; }; template <> struct IsPointerToInt<int *> { static const bool value = true; }; // ... other specializations for the types you are interested in ... 
0
source

All Articles