Namespaces
Variants
Views
Actions

std::add_lvalue_reference, std::add_rvalue_reference

From cppreference.com
< cpp‎ | types
 
 
Metaprogramming library
Type traits
Type categories
(C++11)
(C++11)(DR*)
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
(C++11) 
(C++11)
(C++11)
Type properties
(C++11)
(C++11)
(C++14)
(C++11)(deprecated in C++26)
(C++11)(until C++20*)
(C++11)(deprecated in C++20)
(C++11)
Type trait constants
Metafunctions
(C++17)
Supported operations
Relationships and property queries
Type modifications
(C++11)(C++11)(C++11)
add_lvalue_referenceadd_rvalue_reference
(C++11)(C++11)

Type transformations
(C++11)(deprecated in C++23)
(C++11)(deprecated in C++23)
(C++11)
(C++11)(until C++20*)(C++17)

(C++11)
(C++17)
Compile-time rational arithmetic
Compile-time integer sequences
 
Defined in header <type_traits>
template< class T >
struct add_lvalue_reference;
(1) (since C++11)
template< class T >
struct add_rvalue_reference;
(2) (since C++11)

Creates an lvalue or rvalue reference type of T.

 Type trait  The type referred by the nested type type
 T is a referenceable type   T is not a referenceable type 
(1) T&[1] T
(2) T&&[2]
  1. This rule reflects the semantics of reference collapsing.
  2. This rule reflects the semantics of reference collapsing. Note that std::add_rvalue_reference<T&>::type is T&, which is not an rvalue reference type.

If the program adds specializations for any of the templates described on this page, the behavior is undefined.

Contents

[edit] Nested types

Name Definition
type determined as above

[edit] Helper types

template< class T >
using add_lvalue_reference_t = typename add_lvalue_reference<T>::type;
(since C++14)
template< class T >
using add_rvalue_reference_t = typename add_rvalue_reference<T>::type;
(since C++14)

[edit] Notes

The major difference to directly using T& or T&& is that T can be a non-