std::function::operator()
提供: cppreference.com
< cpp | utility | functional | function
![]() |
このページは、Google 翻訳を使って英語版から機械翻訳されました。
翻訳には誤りや奇妙な言い回しがあるかもしれません。文章の上にポインタをおくと、元の文章が見れます。誤りを修正して翻訳を改善する手助けをしてください。翻訳についての説明は、ここをクリックしてください。 |
R operator()( ArgTypes... args ) const; |
(C++11およびそれ以降) | |
Calls the stored callable function target with the parameters args
.
目次 |
[編集] パラメータ
args | - | parameters to pass to the stored callable function target |
[編集] 値を返します
None if R
is void. Otherwise the return value of the invocation of the stored callable object.
[編集] 例外
- std::bad_function_call if *this does not store a callable function target, !*this == true.
[編集] 例
The following example shows how std::function can passed to other functions by value. Also, it shown how std::function can store lambdas.
このコードを実行します
#include <iostream> #include <functional> void call(std::function<int()> f) // can be passed by value { std::cout << f() << '\n'; } int normal_function() { return 42; } int main() { int n = 1; std::function<int()> f = [&n](){ return n; }; call(f); n = 2; call(f); f = normal_function; call(f); }
出力:
1 2 42
[編集] 参照
This section is incomplete |