名前空間
変種
操作

std::unwrap_reference, std::unwrap_ref_decay

提供: cppreference.com
< cpp‎ | utility‎ | functional
 
 
ユーティリティライブラリ
汎用ユーティリティ
日付と時間
関数オブジェクト
書式化ライブラリ (C++20)
(C++11)
関係演算子 (C++20で非推奨)
整数比較関数
(C++20)
スワップと型操作
(C++14)
(C++11)
(C++11)
(C++11)
(C++17)
一般的な語彙の型
(C++11)
(C++17)
(C++17)
(C++17)
(C++17)

初等文字列変換
(C++17)
(C++17)
 
関数オブジェクト
関数ラッパー
(C++11)
(C++11)
関数の部分適用
(C++20)
(C++11)
関数呼び出し
(C++17)
恒等関数オブジェクト
(C++20)
参照ラッパー
(C++11)(C++11)
unwrap_referenceunwrap_ref_decay
(C++20)(C++20)
演算子ラッパー
否定子
(C++17)
検索子
制約付き比較子
古いバインダとアダプタ
(C++17未満)
(C++17未満)
(C++17未満)
(C++17未満)
(C++17未満)(C++17未満)(C++17未満)(C++17未満)
(C++20未満)
(C++20未満)
(C++17未満)(C++17未満)
(C++17未満)(C++17未満)

(C++17未満)
(C++17未満)(C++17未満)(C++17未満)(C++17未満)
(C++20未満)
(C++20未満)
 
ヘッダ <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) Tstd::reference_wrapper<U> であれば U&、そうでなければ T

2) std::decay_t<T>std::reference_wrapper<U> であれば U&、そうでなければ std::decay_t<T>

[編集] ヘルパー型

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_decaystd::make_pair および std::make_tuple が用いるのと同じ変換を行います。

[編集]

[編集] 関連項目

CopyConstructible かつ CopyAssignable な参照ラッパー
(クラステンプレート) [edit]
引数の型によって定義された型の pair オブジェクトを作成します
(関数テンプレート) [edit]
引数の型によって定義される型の tuple オブジェクトを作成します
(関数テンプレート) [edit]