I want to implement is_pointer. I want something like this:
template
bool is_pointer( T t )
{
// implementation
} // return true or fa
template
struct is_pointer_type
{
enum { value = false };
};
template
struct is_pointer_type
{
enum { value = true };
};
template
bool is_pointer(const T&)
{
return is_pointer_type::value;
}
Johannes noted:
This is actually missing specializations for T *const, T *volatile and T * const volatile i think.
Solution:
template
struct remove_const
{
typedef T type;
};
template
struct remove_const
{
typedef T type;
};
template
struct remove_volatile
{
typedef T type;
};
template
struct remove_volatile
{
typedef T type;
};
template
struct remove_cv : remove_const::type> {};
template
struct is_unqualified_pointer
{
enum { value = false };
};
template
struct is_unqualified_pointer
{
enum { value = true };
};
template
struct is_pointer_type : is_unqualified_pointer::type> {};
template
bool is_pointer(const T&)
{
return is_pointer_type::value;
}
...but of course this is just reinventing the std::type_traits wheel, more or less :)