std::reference_wrapper<T>::reference_wrapper
From cppreference.com
< cpp | utility | functional | reference wrapper
C++
Feature test macros (C++20)
Concepts library (C++20)
Metaprogramming library (C++11)
Ranges library (C++20)
Filesystem library (C++17)
Concurrency support library (C++11)
Execution control library (C++26)
Utilities library
Relational operators (deprecated in C++20)
Integer comparison functions
Swap and type operations
Common vocabulary types
Type support (basic types, RTTI)
Library feature-test macros (C++20)
(C++11)
(C++20)
(C++26)
(C++20)
Coroutine support (C++20)
Contract support (C++26)
(C++20)(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)(C++20)(C++20)
(C++20)(C++20)(C++20)
General utilities
(C++20)(C++20)(C++20)
(C++20)(C++20)(C++20)
(C++20)
Function objects
Old binders and adaptors
(C++11)
(C++23)
(C++26)
(C++26)
(C++11)
(C++11)
(C++20)(C++23)
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)(C++11)
(C++20)(C++20)
(C++14)
(C++14)
(C++14)
(C++14)
(C++14)
(C++14)
(C++14)
(C++14)
(C++14)
(C++17)
(C++17)
(C++17)
(C++17)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(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++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*)
std::reference_wrapper
Member functions
reference_wrapper::reference_wrapper
Non-member functions
(C++26)(C++26)
Deduction guides (C++17)
Helper classes
template< class U >
reference_wrapper( U&& x ) noexcept(/*see below*/) ;
(1)
(since C++11) reference_wrapper( U&& x ) noexcept(/*see below*/) ;
(constexpr since C++20)
reference_wrapper( const reference_wrapper& other ) noexcept;
(2)
(since C++11) (constexpr 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().
[edit] Parameters
x
-
an object to wrap
other
-
another reference wrapper
[edit] Exceptions
1)
noexcept specification:
where noexcept(noexcept(FUN(std::declval <U>())))
FUN
is the set of imaginary functions described in the description above.[edit] Example
This section is incomplete
Reason: no example
Reason: no example
[edit] 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 interfereswith overload resolution in some cases |
replaced with a constructor template |