# std::remove_pointer

> C++ Atlas: `cppatlas.com/w/cpp/types/remove_pointer` | Source: https://en.cppreference.com/w/cpp/types/remove_pointer | Domain: Type support | Standards: C++11, C++14

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.

## Official Specification Summary (cppreference)

```cpp
// Defined in header <type_traits>

template< class T >
struct remove_pointer; // (since C++11)
```

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`.

If the program adds specializations for `std::remove_pointer`, the behavior is undefined.

### Member types

**Name — Definition**

- `type`: the type pointed to by `T` or `T` if it's not a pointer

### Helper types

```cpp
template< class T >
using remove_pointer_t = typename remove_pointer<T>::type; // (since C++14)
```

### Possible implementation

```cpp
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

```cpp
#include <type_traits>

static_assert
(
    std::is_same_v<int, int> == true &&
    std::is_same_v<int, int*> == false &&
    std::is_same_v<int, int**> == false &&
    std::is_same_v<int, std::remove_pointer_t<int>> == true &&
    std::is_same_v<int, std::remove_pointer_t<int*>> == true &&
    std::is_same_v<int, std::remove_pointer_t<int**>> == false &&
    std::is_same_v<int, std::remove_pointer_t<int* const>> == true &&
    std::is_same_v<int, std::remove_pointer_t<int* volatile>> == true &&
    std::is_same_v<int, std::remove_pointer_t<int* const volatile>> == true
);

int main() {}
```

### See also

- [`is_pointer`](https://en.cppreference.com/w/cpp/types/is_pointer) (C++11): checks if a type is a pointer type (class template)
- [`add_pointer`](https://en.cppreference.com/w/cpp/types/add_pointer) (C++11): adds a pointer to the given type (class template)

---
Attribution: content from https://en.cppreference.com/w/cpp/types/remove_pointer (cppreference.com), licensed under CC-BY-SA 3.0 and GFDL. Modified: converted to markdown, study notes added. Offline snapshot of 9 February 2025.