std::unwrap_reference, std::unwrap_ref_decay_C++中文网
| 定义于头文件 |
||
| 定义于头文件 |
||
| template< class T > |
(1) | (C++20 起) |
| template< class T > |
(2) | (C++20 起) |
1) 若 T 为某类型 U 的 std::reference_wrapper<U> ,则提供指名 U& 的成员 typedef type ;否则提供指名 T 的成员 typedef type 。
2) 若 T 为某类型 U 的 std::reference_wrapper<U> ,忽略 cv 限定和引用,则提供指名 U& 的成员 typedef type ;否则提供指名 std::decay_t<T> 的成员 typedef type 。
添加此页面上描述的任何模板的特化的程序行为未定义。
成员类型
辅助类型
| template<class T> |
(1) | (C++20 起) |
| template<class T> |
(2) | (C++20 起) |
可能的实现
template <class T> struct unwrap_reference { using type = T; }; template <class U> struct unwrap_reference<std::reference_wrapper<U>> { using type = U&; }; template< class T > struct unwrap_ref_decay : std::unwrap_reference<std::decay_t<T>> {};
注解
std::unwrap_ref_decay 进行与 std::make_pair 及 std::make_tuple 所用者相同的变换。