Namespaces
Variants
Actions

std::unwrap_reference, std::unwrap_ref_decay

From cppreference.com
< cpp‎ | utility‎ | functional
 
 
Utilities library
General utilities
Relational operators (deprecated in C++20)
 
Function objects
Function invocation
(C++17)(C++23)
Identity function object
(C++20)
Reference wrappers
(C++11)(C++11)
unwrap_referenceunwrap_ref_decay
(C++20)(C++20)
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)

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++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*)
 
Defined in header <type_traits>
Defined in header <functional>
template< class T >
struct unwrap_reference;
(1) (since C++20)
template< class T >
struct unwrap_ref_decay;
(2) (since C++20)

Unwraps any std::reference_wrapper: changing std::reference_wrapper<U> to U&.

1) If T is a specialization of std::reference_wrapper, unwraps it; otherwise, T remains the same.
2) If the decayed T is a specialization of std::reference_wrapper, unwraps it; otherwise, T is decayed.

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

Contents

[edit] Nested types

Type Definition
type

(1) U& if T is std::reference_wrapper<U>; T otherwise
(2) U& if std::decay_t<T> is std::reference_wrapper<U>; std::decay_t<T> otherwise

[edit] Helper types

template<class T>
using unwrap_reference_t = unwrap_reference<T>::type;
(1) (since C++20)
template<class T>
using unwrap_ref_decay_t = unwrap_ref_decay<T>::type;
(2) (since C++20)

[