std::unwrap_reference, std::unwrap_ref_decay
提供: cppreference.com
<tbody>
</tbody>
| ヘッダ <functional> で定義
|
||
template< class T > struct unwrap_reference; |
(1) | (C++20以上) |
template< class T > struct unwrap_ref_decay; |
(2) | (C++20以上) |
1)
T が何らかの型 U に対する std::reference_wrapper<U> である場合は、 U& を表すメンバ型 type を提供します。 そうでなければ、 T を表すメンバ型 type を提供します。2)
T が何らかの型 U に対する std::reference_wrapper<U> である (cv 修飾および参照性は無視します) 場合は、 U& を表すメンバ型 type を提供します。 そうでなければ、 std::decay_t<T> を表すメンバ型 type を提供します。メンバ型
| 名前 | 定義 |
type
|
1) 2) |
ヘルパー型
<tbody> </tbody> template<class T> using unwrap_reference_t = typename unwrap_reference<T>::type; |
(1) | (C++20以上) |
template<class T> using unwrap_ref_decay_t = typename unwrap_ref_decay<T>::type; |
(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 が用いるのと同じ変換を行います。
例
| This section is incomplete Reason: no example |
関連項目
(C++11) |
CopyConstructible かつ CopyAssignable な参照ラッパー (クラステンプレート) |
引数の型によって定義された型の pair オブジェクトを作成します (関数テンプレート) | |
引数の型によって定義される型の tuple オブジェクトを作成します (関数テンプレート) |