名前空間
変種
操作

std::reference_wrapper<T>::operator()

提供: cppreference.com
 
 
ユーティリティライブラリ
汎用ユーティリティ
日付と時間
関数オブジェクト
書式化ライブラリ(C++20)
(C++11)
関係演算子 (C++20で非推奨)
整数比較関数
(C++20)
スワップと型操作
(C++14)
(C++11)
(C++11)
(C++11)
(C++17)
一般的な語彙の型
(C++11)
(C++17)
(C++17)
(C++17)
(C++17)

初等文字列変換
(C++17)
(C++17)
 
関数オブジェクト
関数ラッパー
(C++11)
(C++11)
関数の部分適用
(C++20)
(C++11)
関数呼び出し
(C++17)
恒等関数オブジェクト
(C++20)
参照ラッパー
(C++11)(C++11)
演算子ラッパー
否定子
(C++17)
検索子
古いバインダとアダプタ
(C++17未満)
(C++17未満)
(C++17未満)
(C++17未満)
(C++17未満)(C++17未満)(C++17未満)(C++17未満)
(C++20未満)
(C++20未満)
(C++17未満)(C++17未満)
(C++17未満)(C++17未満)

(C++17未満)
(C++17未満)(C++17未満)(C++17未満)(C++17未満)
(C++20未満)
(C++20未満)
 
 
template<class... ArgTypes>

typenamestd::result_of<T&(ArgTypes&&...)>::type

    operator()( ArgTypes&&... args)const;
(C++11以上)
(C++17未満)
template<class... ArgTypes>

std::invoke_result_t<T&, ArgTypes...>

    operator()( ArgTypes&&... args)const;
(C++17以上)
(C++20未満)
template<class... ArgTypes>

constexpr std::invoke_result_t<T&, ArgTypes...>

    operator()( ArgTypes&&... args)const;
(C++20以上)

格納されている参照の指す Callable なオブジェクトを呼びます。 この関数は格納されている参照が Callable なオブジェクトを指す場合にのみ利用可能です。

T は完全型でなければなりません。

目次

[編集]引数

args - 呼ばれる関数に渡す引数

[編集]戻り値

呼ばれた関数の戻り値。


[編集]

#include <iostream>#include <functional>   void f1(){std::cout<<"reference to function called\n";}void f2(int n){std::cout<<"bind expression called with "<< n <<" as the argument\n";}   int main(){std::reference_wrapper<void()> ref1 =std::ref(f1); ref1();   auto b =std::bind(f2, std::placeholders::_1);auto ref2 =std::ref(b); ref2(7);   auto c =[]{std::cout<<"lambda function called\n";};auto ref3 =std::ref(c); ref3();}

出力:

reference to function called bind expression called with 7 as the argument lambda function called

[編集]関連項目

格納されている参照にアクセスします
(パブリックメンバ関数)[edit]
close