GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • cpprefjp - C++日本語リファレンス
  • GitHub Project

This view

  • Original page
  • New address

GeezerVison is showing cpprefjp.github.io — std::move_only_function::operator() - cpprefjp C++日本語リファレンス

  1. リファレンス
  2. functional
  3. move_only_function
  4. operator()

最終更新日時: 2026年09月11日 13時06分31秒 (JST)
Akira Takahashi が更新

履歴 編集

function
<functional>

std::move_only_function::operator()(C++23)

R operator()(ArgTypes... args) /*cv*/ /*ref*/ noexcept(/*noex*/);

概要

関数を呼び出す。

operator()のCV修飾子 cv, 参照修飾子 ref, noexcept例外指定 noex は、move_only_functionに指定するテンプレートパラメータR(ArgTypes...)部のものと等しい。

説明用のプレースホルダ inv-quals を次のように定義する :

  • ref が空(参照修飾無し)ならば、cv&
  • そうでなければ、cv ref

事前条件

*thisは関数ポインタまたは関数オブジェクトを保持していること。

効果

*thisが保持しているF型の関数ポインタまたは関数オブジェクトfに対して、INVOKE<R>(static_cast<F /*inv-quals*/>(f), std::forward<ArgTypes>(args)...)を行う。

戻り値

R型がvoidの場合は何も返さない。そうでなければ、関数呼び出しの戻り値を返す。

例

#include <iostream>
#include <functional>

int ident(int x)
{ return x; }

int main()
{
  std::move_only_function<int(int)> f = ident;

  // 関数呼び出し : 保持しているident()関数を呼び出す
  int result = f(1);

  std::cout << result << std::endl;
}

出力

1

バージョン

言語

  • C++23

処理系

  • Clang: ??
  • GCC: 12.1 ✅
  • Visual C++: ??

参照

  • P0288R9 move_only_function
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.