Namespaces
Variants

std::copyable_function:: copyable_function

From ja.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* )
copyable_function ( ) noexcept ;
(1) (C++26以降)
copyable_function ( std:: nullptr_t ) noexcept ;
(2) (C++26以降)
copyable_function ( const copyable_function & other ) ;
(3) (C++26以降)
copyable_function ( copyable_function && other ) noexcept ;
(4) (C++26以降)
template < class F >
copyable_function ( F && f ) ;
(5) (C++26以降)
template < class T, class ... CArgs >
explicit copyable_function ( std:: in_place_type_t < T > , CArgs && ... args ) ;
(6) (C++26以降)
template < class T, class U, class ... CArgs >

explicit copyable_function ( std:: in_place_type_t < T > ,

std:: initializer_list < U > il, CArgs && ... args ) ;
(7) (C++26以降)

新しい std::copyable_function を作成します。

1,2) デフォルトコンストラクタと nullptr を受け取るコンストラクタは、空の std::copyable_function を構築します。
3) コピーコンストラクタは、 other のターゲットのコピーをターゲットとする std::copyable_function を構築する。 other が空の場合、空の std::copyable_function を構築する。
4) ムーブコンストラクタは、 other のターゲットを持つ std::copyable_function を構築する。 other はムーブ構築後、有効だが未規定の状態となる。
5) VTを std:: decay_t < F > とする。fが空の関数ポインタ、空のメンバポインタ値、または空の std::copyable_function (他の特殊化でも可)である場合、空の std::copyable_function を構築する。それ以外の場合、 std::copyable_function を構築し、そのターゲットは型 VT を持ち、 std:: forward < F > ( f ) で直接非リスト初期化される。
  • このオーバーロードは、VTがcopyable_functionと同じでなく、かつ std::in_place_type_t の特殊化でもなく、かつ /*is-callable-from*/ < VT > (下記参照)が true である場合にのみ、オーバーロード解決に参加する。
  • プログラムは、 std:: is_constructible_v < VT, F > または std:: is_copy_constructible_v < VT > が true でない場合、不適格となる。
6) VTを std:: decay_t < T > とする。std::copyable_functionを構築し、そのターゲットは型VTを持ち、 std:: forward < CArgs > ( args ) ... で直接非リスト初期化される。
  • このオーバーロードは、 std:: is_constructible_v < VT, CArgs... > と /*is-callable-from*/ < VT > の両方が true である場合にのみ、オーバーロード解決に参加する。
  • VTがTと同じ型ではない場合、または std:: is_copy_constructible_v < VT > が true でない場合、プログラムは不適格となる。
7) VTを std:: decay_t < T > とする。std::copyable_functionを構築し、そのターゲットの型はVTであり、 il, std:: forward < CArgs > ( args ) ... で直接非リスト初期化される。

コンストラクタ (5-7) については、 VT が Destructible 要件と CopyConstructible 要件の両方を満たさない限り、動作は未定義です。

定数 /*is-callable-from*/ < VT > は、 std::copyable_function のテンプレートパラメータにおける cv 、 ref 、および noex に依存しており、以下の通りです:

HTMLタグ、属性、タグ内のテキスト、C++固有の用語は翻訳せず、元のフォーマットを保持しました。 HTMLタグ、属性、および``タグ内のC++コードは翻訳せず、元のフォーマットを保持しました。C++固有の用語(`noexcept`、`std::is_nothrow_invocable_r_v`など)は翻訳していません。 HTMLタグ、属性、タグ内のテキスト、C++固有の用語は翻訳せず、元のフォーマットを保持しました。 HTMLタグ、属性、C++コード内のテキストは翻訳せず、元のフォーマットを保持しました。C++固有の用語(`const`、`noexcept`、`std::is_nothrow_invocable_r_v`など)は翻訳していません。 **翻訳結果:** HTMLタグ、属性、および``、`
`、``タグ内のテキストは翻訳せず、元のフォーマットを保持します。C++固有の用語は翻訳しません。

このコードはC++のテンプレートメタプログラミングに関連するもので、翻訳対象の自然言語テキストは含まれていません。すべてがC++コードまたはHTMLマークアップであるため、翻訳は不要です。
**翻訳結果:** HTMLタグ、属性、``、`
`、``タグ内のテキスト、およびC++固有の用語は翻訳せず、元のフォーマットを保持しています。
**翻訳結果:** HTMLタグ、属性、``、`
`、``タグ内のテキスト、およびC++固有の用語は翻訳せず、元のフォーマットを保持しました。
cv ref noexcept ( noex ) /*呼び出し可能か*/ < VT >
noexcept ( false ) std:: is_invocable_r_v < R, VT, Args... > &&

std:: is_invocable_r_v < R, VT & , Args... >

noexcept ( true ) std:: is_nothrow_invocable_r_v < R, VT, Args... > &&

std:: is_nothrow_invocable_r_v < R, VT & , Args... >

const noexcept ( false ) std:: is_invocable_r_v < R, const VT, Args... > &&

std:: is_invocable_r_v < R, const VT & , Args... >

const noexcept ( true ) std:: is_nothrow_invocable_r_v < R, const VT, Args... > &&

std:: is_nothrow_invocable_r_v < R, const VT & , Args... >

& noexcept ( false ) std:: is_invocable_r_v < R, VT & , Args... >
& noexcept ( true ) std:: is_nothrow_invocable_r_v < R, VT & , Args... >
const & noexcept ( false ) std:: is_invocable_r_v < R, const VT & , Args... >
const & noexcept ( true ) std:: is_nothrow_invocable_r_v < R, const VT & , Args... >
&& noexcept ( false ) std:: is_invocable_r_v < R, VT, Args... >
&& noexcept ( true ) std:: is_nothrow_invocable_r_v < R, VT, Args... >
const && noexcept ( false ) std:: is_invocable_r_v < R, const VT, Args... >
const && noexcept ( true ) std:: is_nothrow_invocable_r_v < R, const VT, Args... >

目次

パラメータ

other - コピー元またはムーブ元となる別の std::copyable_function
f - ラップする関数または Callable オブジェクト
args - ターゲットオブジェクトを構築するための引数
il - ターゲットオブジェクトを構築するための std::initializer_list

例外

3) メモリ確保失敗時に std::bad_alloc をスローする可能性がある、またはターゲットの初期化でスローされた例外を伝播する可能性がある。
5-7) メモリ確保の失敗時には std::bad_alloc をスローする可能性があり、またはターゲットの初期化によってスローされた例外を伝播する可能性があります。 VT が関数ポインタ型または std::reference_wrapper の特殊化である場合、例外はスローされません。

例

関連項目

新しい std::function インスタンスを構築する
( std::function<R(Args...)> の公開メンバ関数)
新しい std::move_only_function オブジェクトを構築する
( std::move_only_function の公開メンバ関数)