std::reference_wrapper<T>::reference_wrapper

From cppreference.com
 
 
Utilities library
General utilities
Date and time
Function objects
Formatting library (C++20)
(C++11)
Relational operators (deprecated in C++20)
Integer comparison functions
(C++20)(C++20)(C++20)   
(C++20)
Swap and type operations
(C++14)
(C++11)
(C++11)
(C++11)
(C++17)
Common vocabulary types
(C++11)
(C++17)
(C++17)
(C++17)
(C++11)
(C++17)
(C++23)
Elementary string conversions
(C++17)
(C++17)
 
Function objects
Function wrappers
(C++11)
(C++11)
Partial function application
(C++20)(C++23)
(C++11)
Function invocation
(C++17)(C++23)
Identity function object
(C++20)
Reference wrappers
(C++11)(C++11)
Transparent operator wrappers
(C++14)
(C++14)
(C++14)
(C++14)  
(C++14)
(C++14)
(C++14)
(C++14)
(C++14)
(C++14)
(C++14)
(C++14)
(C++14)

Negators
(C++17)
Searchers
Constrained comparators
Old binders and adaptors
(until C++17*)
(until C++17*)
(until C++17*)
(until C++17*)
(until C++17*)(until C++17*)(until C++17*)(until C++17*)
(until C++20*)
(until C++20*)
(until C++17*)(until C++17*)
(until C++17*)(until C++17*)

(until C++17*)
(until C++17*)(until C++17*)(until C++17*)(until C++17*)
(until C++20*)
(until C++20*)
 
 
(1)
template< class U >
reference_wrapper( U&& x ) noexcept(/*see below*/) ;
(since C++11)
(until C++20)
template< class U >
constexpr reference_wrapper( U&& x ) noexcept(/*see below*/) ;
(since C++20)
(2)
reference_wrapper( const reference_wrapper& other ) noexcept;
(since C++11)
(until C++20)
constexpr reference_wrapper( const reference_wrapper& other ) noexcept;
(since C++20)

Constructs a new reference wrapper.

1) Converts x to T& as if by T& t = std::forward<U>(x);, then stores a reference to t. This overload participates in overload resolution only if typename std::decay<U>::type is not the same type as reference_wrapper and the expression FUN(std::declval<U>()) is well-formed, where FUN names the set of imaginary functions
void FUN(T&) noexcept;
void FUN(T&&) = delete;
2) Copy constructor. Stores a reference to other.get().

Parameters

x - an object to wrap
other - another reference wrapper

Exceptions

1)
noexcept specification:  
noexcept(noexcept(FUN(std::declval<U>())))
where FUN is the set of imaginary functions described in the description above.

Example

Defect reports

The following behavior-changing defect reports were applied retroactively to previously published C++ standards.

DR Applied to Behavior as published Correct behavior
LWG 2993 C++11 deleted reference_wrapper(T&&) constructor interferes
with overload resolution in some cases
replaced with a constructor template