# std::remove_reference

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

If the type T is a reference type, provides the member typedef type which is the type referred to by T. Otherwise type is T.

## Official Specification Summary (cppreference)

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

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

If the type `T` is a reference type, provides the member typedef `type` which is the type referred to by `T`. Otherwise `type` is `T`.

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

### Member types

**Name — Definition**

- `type`: the type referred by `T` or `T` if it is not a reference

### Helper types

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

### Possible implementation

```cpp
template<class T> struct remove_reference { typedef T type; };
template<class T> struct remove_reference<T&> { typedef T type; };
template<class T> struct remove_reference<T&&> { typedef T type; };
```

### Example

```cpp
#include <iostream>
#include <type_traits>

int main()
{
    std::cout << std::boolalpha;

    std::cout << "std::remove_reference<int>::type is int? "
              << std::is_same<int, std::remove_reference<int>::type>::value << '\n';
    std::cout << "std::remove_reference<int&>::type is int? "
              << std::is_same<int, std::remove_reference<int&>::type>::value << '\n';
    std::cout << "std::remove_reference<int&&>::type is int? "
              << std::is_same<int, std::remove_reference<int&&>::type>::value << '\n';
    std::cout << "std::remove_reference<const int&>::type is const int? "
              << std::is_same<const int,
                              std::remove_reference<const int&>::type>::value << '\n';
}
```

Output:

```text
std::remove_reference<int>::type is int? true
std::remove_reference<int&>::type is int? true
std::remove_reference<int&&>::type is int? true
std::remove_reference<const int&>::type is const int? true
```

### See also

- [`is_reference`](https://en.cppreference.com/w/cpp/types/is_reference) (C++11): checks if a type is either an *lvalue reference* or *rvalue reference* (class template)
- [`add_lvalue_reference`](https://en.cppreference.com/w/cpp/types/add_reference) (C++11), [`add_rvalue_reference`](https://en.cppreference.com/w/cpp/types/add_reference) (C++11): adds an *lvalue* or *rvalue* reference to the given type (class template)
- [`remove_cvref`](https://en.cppreference.com/w/cpp/types/remove_cvref) (C++20): combines `std::remove_cv` and `std::remove_reference` (class template)

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