Namespaces
Variants

std::experimental::ranges:: invoke

From cppreference.net
template < class F, class ... Args >
std:: result_of_t < F && ( Args && ... ) > invoke ( F && f, Args && ... args ) ;
(ranges TS)

Callable オブジェクト f をパラメータ args で呼び出し、その結果を返します。具体的には、 return INVOKE ( std:: forward < F > ( f ) , std:: forward < Args > ( args ) ... ) ; によって実行されるかのように動作します。ここで INVOKE(f, t1, t2, ..., tN) は以下のように定義されます:

  • std::is_base_of<T, std::decay_t<decltype(t1)>>::value true の場合、 INVOKE(f, t1, t2, ..., tN) (t1.*f)(t2, ..., tN) と等価である。
  • それ以外の場合、 INVOKE(f, t1, t2, ..., tN) ((*t1).*f)(t2, ..., tN) と等価である。
  • std:: is_base_of < T, std:: decay_t < decltype ( t1 ) >> :: value true の場合、 INVOKE ( f, t1 ) t1. * f と等価である。
  • それ以外の場合、 INVOKE ( f, t1 ) ( * t1 ) . * f と等価である。
  • そうでなければ、 INVOKE ( f, t1, t2, ..., tN ) f ( t1, t2, ..., tN ) と等価である(すなわち、 f FunctionObject である)。

パラメータ

f - Callable 呼び出されるオブジェクト
args - f に渡す引数

関連項目

(C++17) (C++23)
任意の Callable オブジェクトを指定された引数で呼び出し 戻り値の型を指定可能 (C++23以降)
(関数テンプレート)