A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://cplusplus.com/reference/type_traits/add_rvalue_reference/ below:

class template

<type_traits>

std::add_rvalue_reference
template <class T> struct add_rvalue_reference;

Add rvalue reference

Obtains the rvalue reference type that refers to T.

The transformed type is aliased as member type add_rvalue_reference::type as follows:


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 type definition type If T is an object or function type: T&&
Otherwise: T
Example
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
// add_rvalue_reference
#include <iostream>
#include <type_traits>

int main() {
  typedef std::add_rvalue_reference<int>::type A;    // int&&
  typedef std::add_rvalue_reference<int&>::type B;   // int&  (no change)
  typedef std::add_rvalue_reference<int&&>::type C;  // int&& (no change)
  typedef std::add_rvalue_reference<int*>::type D;   // int*&&

  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: false
C: true
D: false


See also
remove_reference
Remove reference (class template)
add_lvalue_reference
Add lvalue reference (class template)
add_pointer
Add pointer (class template)
add_const
Add const qualification (class template)

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4