std::remove_pointer (3) - Linux Manuals
std::remove_pointer: std::remove_pointer
Command to display std::remove_pointer
manual in Linux: $ man 3 std::remove_pointer
NAME
std::remove_pointer - std::remove_pointer
Synopsis
Defined in header <type_traits>
template< class T > (since C++11)
struct remove_pointer;
Provides the member typedef type which is the type pointed to by T, or, if T is not a pointer, then type is the same as T.
Member types
Name Definition
type the type pointed to by T or T if it's not a pointer
Helper types
template< class T > (since C++14)
using remove_pointer_t = typename remove_pointer<T>::type;
Possible implementation
template< class T > struct remove_pointer {typedef T type;};
template< class T > struct remove_pointer<T*> {typedef T type;};
template< class T > struct remove_pointer<T* const> {typedef T type;};
template< class T > struct remove_pointer<T* volatile> {typedef T type;};
template< class T > struct remove_pointer<T* const volatile> {typedef T type;};
Example
// Run this code
#include <iostream>
#include <type_traits>
template<class T1, class T2>
void print_is_same()
{
std::cout << std::is_same<T1, T2>() << '\n';
}
void print_separator()
{
std::cout << "-----\n";
}
int main()
{
std::cout << std::boolalpha;
print_is_same<int, int>(); // true
print_is_same<int, int*>(); // false
print_is_same<int, int**>(); // false
print_separator();
print_is_same<int, std::remove_pointer<int>::type>(); // true
print_is_same<int, std::remove_pointer<int*>::type>(); // true
print_is_same<int, std::remove_pointer<int**>::type>(); // false
print_separator();
print_is_same<int, std::remove_pointer<int* const>::type>(); // true
print_is_same<int, std::remove_pointer<int* volatile>::type>(); // true
print_is_same<int, std::remove_pointer<int* const volatile>::type>(); // true
}
Output:
true
false
false
-----
true
true
false
-----
true
true
true
See also
is_pointer checks if a type is a pointer type
(class template)
(C++11)
add_pointer adds a pointer to the given type
(class template)
(C++11)
Pages related to std::remove_pointer
- std::remove_all_extents (3) - std::remove_all_extents
- std::remove_const (3)
- std::remove_copy,std::remove_copy_if (3) - std::remove_copy,std::remove_copy_if
- std::remove_cv,std::remove_const,std::remove_volatile (3) - std::remove_cv,std::remove_const,std::remove_volatile
- std::remove_cv (3)
- std::remove_cvref (3) - std::remove_cvref
- std::remove_extent (3) - std::remove_extent
- std::remove_reference (3) - std::remove_reference
- std::remove_volatile (3)
- std::remove,std::remove_if (3) - std::remove,std::remove_if
- std::remove (3) - std::remove
- std::remainder,std::remainderf,std::remainderl (3) - std::remainder,std::remainderf,std::remainderl