std::function<R(Args...)>::target_type
提供: cppreference.com
< cpp | utility | functional | function
const std::type_info& target_type() const noexcept; |
(C++11以上) | |
格納されている関数の型を返します。
目次 |
[編集] 引数
(なし)
[編集] 戻り値
格納されている関数が型 T
を持っていれば typeid(T)、そうでなければ typeid(void)。
[編集] 例
Run this code
#include <functional> #include <iostream> int f(int a) { return -a; } int main() { // fn1 and fn2 have the same type, but their targets do not std::function<int(int)> fn1(f), fn2([](int a) {return -a;}); std::cout << fn1.target_type().name() << '\n' << fn2.target_type().name() << '\n'; }
出力例:
int (*)(int) main::$_0
[編集] 関連項目
格納されているターゲットを指すポインタを返します (パブリックメンバ関数) |