VOOZH about

URL: https://www.geeksforgeeks.org/cpp/boost-is_pointer-template-in-c/

⇱ boost is_pointer template in C++ - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

boost is_pointer template in C++

Last Updated : 31 Mar, 2020
The is_pointer template of Boost library is used to check whether the given type is a pointer or not. It returns a boolean value showing the same. Header Files:
#include "boost/type_traits.hpp"
 or 
#include "boost/type_traits/is_pointer.hpp"
Template Class:
template <class T>
struct is_pointer : public true_type-or-false_type {};
If T is a pointer type then inherits from true_type else inherits from false_type. Syntax:
boost::is_pointer::value
boost::is_pointer::value_type
Parameter: This template accepts a single parameter T(Trait class) to check whether T is a pointer type or not. Accepted Arguments: This template accept the below arguments:
typename T
T *volatile
T *const volatile
T *const
T *
Return Value: This template returns a boolean value as shown below:
  • True: If the type is a pointer value.
  • False: If the type is a not pointer value.
Below programs illustrates the std::is_pointer template in C++ STL: Program 1:
Output:
is_pointer_type: 
int *: 1
char *: 1
pointer to integer: 1
pointer to 1-D array: 1
1-D array :0
Program 2:
Output:
is_pointer_type: 
pointer to fun: 1
instance of a structure: 0
pointer to instance of a structure: 1
instance of a class: 0
pointer to instance of a class: 1
Comment
Article Tags: