std:: is_invocable, std:: is_invocable_r, std:: is_nothrow_invocable, std:: is_nothrow_invocable_r
|
ヘッダーで定義
<type_traits>
|
||
|
template
<
class
Fn,
class
...
ArgTypes
>
struct is_invocable ; |
(1) | (C++17以降) |
|
template
<
class
R,
class
Fn,
class
...
ArgTypes
>
struct is_invocable_r ; |
(2) | (C++17以降) |
|
template
<
class
Fn,
class
...
ArgTypes
>
struct is_nothrow_invocable ; |
(3) | (C++17以降) |
|
template
<
class
R,
class
Fn,
class
...
ArgTypes
>
struct is_nothrow_invocable_r ; |
(4) | (C++17以降) |
Fn
、
R
、またはパラメータパック
ArgTypes
内のいずれかの型が完全型でない場合((possibly cv-qualified)
void
、または未知の境界を持つ配列である場合)、動作は未定義です。
上記のテンプレートのインスタンス化が、直接的または間接的に不完全型に依存しており、その型が仮に完全化された場合に異なる結果をもたらす可能性がある場合、その動作は未定義です。
プログラムがこのページで説明されているテンプレートのいずれかに対する特殊化を追加する場合、動作は未定義です。
目次 |
ヘルパー変数テンプレート
|
ヘッダーで定義
<type_traits>
|
||
|
template
<
class
Fn,
class
...
ArgTypes
>
inline
constexpr
bool
is_invocable_v
=
|
(1) | (C++17以降) |
|
template
<
class
R,
class
Fn,
class
...
ArgTypes
>
inline
constexpr
bool
is_invocable_r_v
=
|
(2) | (C++17以降) |
|
template
<
class
Fn,
class
...
ArgTypes
>
inline
constexpr
bool
is_nothrow_invocable_v
=
|
(3) | (C++17以降) |
|
template
<
class
R,
class
Fn,
class
...
ArgTypes
>
inline
constexpr
bool
is_nothrow_invocable_r_v
=
|
(4) | (C++17以降) |
std::integral_constant から継承
メンバ定数
|
value
[static]
|
true
オーバーロード
(1)
の場合、
INVOKE
(
std::
declval
<
Fn
>
(
)
,
std::
declval
<
ArgTypes
>
(
)
...
)
が未評価オペランドとして扱われた際に有効な形式であれば、
false
それ以外の場合
(public static member constant) |
メンバ関数
|
operator bool
|
オブジェクトを
bool
に変換し、
value
を返す
(public member function) |
|
operator()
(C++14)
|
value
を返す
(public member function) |
メンバ型
| 型 | 定義 |
value_type
|
bool |
type
|
std:: integral_constant < bool , value > |
注記
| 機能テスト マクロ | 値 | 標準 | 機能 |
|---|---|---|---|
__cpp_lib_is_invocable
|
201703L
|
(C++17) |
std::is_invocable
,
std::invoke_result
|
例
#include <type_traits> auto func2(char) -> int (*)() { return nullptr; } int main() { static_assert(std::is_invocable_v<int()>); static_assert(not std::is_invocable_v<int(), int>); static_assert(std::is_invocable_r_v<int, int()>); static_assert(not std::is_invocable_r_v<int*, int()>); static_assert(std::is_invocable_r_v<void, void(int), int>); static_assert(not std::is_invocable_r_v<void, void(int), void>); static_assert(std::is_invocable_r_v<int(*)(), decltype(func2), char>); static_assert(not std::is_invocable_r_v<int(*)(), decltype(func2), void>); }
関連項目
|
(C++17)
(C++23)
|
任意の
Callable
オブジェクトを指定された引数で呼び出し
、戻り値の型を指定可能
(C++23以降)
(関数テンプレート) |
|
(C++11)
(C++20で削除)
(C++17)
|
呼び出し可能オブジェクトを引数セットで呼び出した結果の型を推論する
(クラステンプレート) |
|
(C++11)
|
未評価コンテキストで使用するためのテンプレート型引数のオブジェクトへの参照を取得する
(関数テンプレート) |
|
(C++20)
|
呼び出し可能型が指定された引数型のセットで呼び出し可能であることを指定する
(コンセプト) |