class template
<type_traits>

std::remove_reference

template <class T> struct remove_reference;
Remove reference
Obtains the non-reference type to which T refers.

The transformed type is aliased as member type remove_reference::type.

If T is a reference type (either lvalue reference or rvalue reference), this is the type to which it refers. Otherwise, it is the same as T, unchanged.

Notice that this class merely obtains a type using another type as model, but it does not transform values or objects between those types.

Template parameters

T
A type.

Member types

member typedefinition
typeIf T is a reference type, the type referrered to by T.
Otherwise, T.

Example

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
// remove_reference
#include <iostream>
#include <type_traits>

int main() {
  typedef int&& rval_int;
  typedef std::remove_reference<int>::type A;
  typedef std::remove_reference<int&>::type B;
  typedef std::remove_reference<int&&>::type C;
  typedef std::remove_reference<rval_int>::type D;

  std::cout << std::boolalpha;
  std::cout << "typedefs of int:" << std::endl;
  std::cout << "A: " << std::is_same<int,A>::value << std::endl;
  std::cout << "B: " << std::is_same<int,B>::value << std::endl;
  std::cout << "C: " << std::is_same<int,C>::value << std::endl;
  std::cout << "D: " << std::is_same<int,D>::value << std::endl;

  return 0;
}


Output:
typedefs of int:
A: true
B: true
C: true
D: true

See also

add_reference

<type_traits>