Namespaces
Variants

std::move_only_function:: move_only_function

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

explicit move_only_function ( std:: in_place_type_t < T > ,

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

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

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

コンストラクタ (5-7) の場合、 VT Destructible 要件を満たさない場合、または std:: is_move_constructible_v < VT > true であるにもかかわらず VT MoveConstructible 要件を満たさない場合、動作は未定義です。

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

**注記**: 提供されたHTMLコードには翻訳対象となる自然言語テキストが含まれていません。すべての要素は以下のいずれかに該当します: - HTMLタグおよび属性 - ` `タグ内のC++コード - C++固有のキーワード(`noexcept`, `false`など) - 標準ライブラリの型特性(`std::is_invocable_r_v`) - テンプレート構文 したがって、翻訳作業は必要ありません。元のフォーマットとC++コードはすべてそのまま保持されています。 HTMLタグ、属性、および` `タグ内のC++コードは翻訳せず、元のフォーマットを保持しました。C++固有の用語(`noexcept`、`std::is_nothrow_invocable_r_v`など)は翻訳していません。 HTMLタグ、属性、C++コード内のテキストは翻訳せず、元のフォーマットを保持しました。C++固有の用語も翻訳していません。 **翻訳結果:** HTMLタグ、属性、および` `、`
`、``タグ内のテキストは翻訳せず、元のフォーマットを保持します。C++固有の用語も翻訳しません。
- 左側のセル: `& noexcept(true)`(C++コードのため翻訳なし)
- 右側のセル: `std::is_nothrow_invocable_r_v`(C++コードのため翻訳なし)
この構造は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::move_only_function からムーブする
f - ラップする関数または Callable オブジェクト
args - ターゲットオブジェクトを構築するための引数
il - std::initializer_list ターゲットオブジェクトを構築するための

例外

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

関連項目

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