std::reference_wrapper<T>::reference_wrapper
template< class U > reference_wrapper( U&& x ) noexcept(/*see below*/) ; | (1) | |
reference_wrapper( const reference_wrapper& other ) noexcept; | (2) |
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 only participates in overload resolution 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)
where
noexcept specification: noexcept(noexcept(FUN(std::declval<U>())))FUN is the set of imaginary functions described in the description above.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 |
© cppreference.com
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
http://en.cppreference.com/w/cpp/utility/functional/reference_wrapper/reference_wrapper