class template

<type_traits>

std::is_pointer

template <class T> struct is_pointer;

Is pointer


Trait class that identifies whether T is a pointer type.

It inherits from integral_constant as being either true_type or false_type.

Pointer to functions are considered pointer types by this class, but pointers to non-static class members and the type of

nullptr are not (see is_member_object_pointer and is_member_function_pointer).

Template parameters

T
A type.

Member types

Inherited from integral_constant:
member typedefinition
value_typebool
typeeither true_type or false_type

Member constants

Inherited from integral_constant:
member constantdefinition
valueeither true or false

Member functions

Inherited from integral_constant:
operator bool
Returns value (public member function)

Example

1
2
3
4
5
6
7
8
9
10
11
12
13
// is_pointer example
#include <iostream>
#include <type_traits>

int main() {
  std::cout << std::boolalpha;
  std::cout << "is_pointer:" << std::endl;
  std::cout << "int: " << std::is_pointer<int>::value << std::endl;
  std::cout << "int*: " << std::is_pointer<int*>::value << std::endl;
  std::cout << "int**: " << std::is_pointer<int**>::value << std::endl;
  std::cout << "int(*)(int): " << std::is_pointer<int(*)(int)>::value << std::endl;
  return 0;
}

Output:
is_pointer:
int: false
int*: true
int**: true
int(*)(int): true


See also

is_lvalue_reference
Is lvalue reference (class template)
is_rvalue_reference
Is rvalue reference (class template)
is_member_object_pointer
Is member object pointer (class template)
is_member_function_pointer
Is member function pointer (class template)
is_member_pointer
Is member pointer type (class template)
is_function
Is function (class template)