std::copyable_function
| ヘッダ <functional>
|
||
template< class... >
class copyable_function; // not defined
|
で定義 (1) | (C++26以上) |
template< class R, class... Args >
class copyable_function<R(Args...)>;
template< class R, class... Args >
class copyable_function<R(Args...) noexcept>;
template< class R, class... Args >
class copyable_function<R(Args...) &>;
template< class R, class... Args >
class copyable_function<R(Args...) & noexcept>;
template< class R, class... Args >
class copyable_function<R(Args...) &&>;
template< class R, class... Args >
class copyable_function<R(Args...) && noexcept>;
template< class R, class... Args >
class copyable_function<R(Args...) const>;
template< class R, class... Args >
class copyable_function<R(Args...) const noexcept>;
template< class R, class... Args >
class copyable_function<R(Args...) const &>;
template< class R, class... Args >
class copyable_function<R(Args...) const & noexcept>;
template< class R, class... Args >
class copyable_function<R(Args...) const &&>;
template< class R, class... Args >
class copyable_function<R(Args...) const && noexcept>;
|
(2) | (C++26以上) |
クラステンプレート std::copyable_function は、汎用の多相的関数ラッパーです。 std::copyable_function オブジェクトは、任意の コピー構築可能 かつ 呼び出し可能なターゲット(関数、ラムダ式、bind式、その他の関数オブジェクト、メンバ関数へのポインタ、メンバオブジェクトへのポインタ)を格納し、呼び出すことができます。
格納された呼び出し可能オブジェクトは、ターゲットと呼ばれます。 std::copyable_function がターゲットを持たない場合、それはstd::copyable_function空と呼ばれます。 std::function とは異なり、空の std::copyable_function を呼び出すと未定義動作になります。
std::copyable_function は、テンプレート引数で指定された、cv修飾子(volatile は除く)、参照修飾子、およびnoexcept指定子(存在する場合)のすべての可能な組み合わせをサポートします。これらの修飾子と指定子(存在する場合)は、そのoperator()に追加されます。
std::copyable_function は、CopyConstructible と CopyAssignable の要件を満たします。
メンバー型
| 型 | 定義 |
result_type
|
R
|
メンバー関数
新しい
std::copyable_function
オブジェクトを構築する
(public member function) |
|
std::copyable_function
オブジェクトを破棄する
(public member function) |
|
|
ターゲットを置き換えるか破棄する
(public member function) |
|
2つの
std::copyable_function
オブジェクトのターゲットを交換する
(public member function) |
|
std::copyable_function
がターゲットを持っているかチェックする
(public member function) |
|
|
ターゲットを呼び出す
(public member function) |
非メンバー関数
|
(C++26)
|
std::swap
アルゴリズムをオーバーロードする
(関数) |
|
(C++26)
|
std::copyable_function
と
nullptr
を比較する
(関数) |
注記
実装は、小さなサイズの呼び出し可能オブジェクトをstd::copyable_functionオブジェクト内に格納することがあります。このような小さなオブジェクト最適化は、関数ポインタとstd::reference_wrapperの特殊化に対して事実上必須であり、Tについてstd::is_nothrow_move_constructible_v<T>がtrueである型にのみ適用できます。
| 機能テスト マクロ | 値 | 標準 | 機能 |
|---|---|---|---|
__cpp_lib_copyable_function
|
202306L
|
(C++26) |
std::copyable_function
|
例
|
このセクションは不完全です
理由: 例がありません |
関連項目
|
(C++11)
|
任意のコピー構築可能な呼び出し可能オブジェクトのコピー可能ラッパー
(クラステンプレート) |
|
(C++23)
|
特定の呼び出しシグネチャで修飾子をサポートする任意の呼び出し可能オブジェクトのムーブ専用ラッパー
(クラステンプレート) |
|
(C++26)
|
任意の呼び出し可能オブジェクトの非所有ラッパー
(クラステンプレート) |