Namespaces
Variants

std::reference_wrapper<T>:: reference_wrapper

From cppreference.net
Utilities library
Function objects
Function invocation
(C++17) (C++23)
Identity function object
(C++20)
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++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* )
template < class U >
reference_wrapper ( U && x ) noexcept ( /*see below*/ ) ;
(1) (C++11以降)
(C++20以降constexpr)
reference_wrapper ( const reference_wrapper & other ) noexcept ;
(2) (C++11以降)
(C++20以降constexpr)

新しい参照ラッパーを構築します。

1) x T& に変換する( T & t = std:: forward < U > ( x ) ; によって行われるかのように)。その後、 t への参照を格納する。このオーバーロードは、 typename std:: decay < U > :: type reference_wrapper と同じ型ではなく、かつ式 FUN ( std:: declval < U > ( ) ) が適正に形成される場合にのみ、オーバーロード解決に参加する。ここで FUN は以下の仮想関数の集合を指す:
void FUN(T&) noexcept;
void FUN(T&&) = delete;
2) コピーコンストラクタ。 other. get ( ) への参照を格納します。

目次

パラメータ

x - ラップするオブジェクト
other - 別の参照ラッパー

例外

1)
noexcept 指定:
noexcept ( noexcept ( FUN ( std:: declval < U > ( ) ) ) )
ここで FUN は前述の説明で記述されている仮想的な関数の集合です。

欠陥報告

以下の動作変更の欠陥報告書は、以前に公開されたC++規格に対して遡及的に適用されました。

DR 適用対象 公開時の動作 正しい動作
LWG 2993 C++11 削除された reference_wrapper(T&&) コンストラクタが一部の場合において
オーバーロード解決を妨害する
コンストラクタテンプレートで置き換え