std::function::target_type
| const std::type_info& target_type() const; |  | (since C++11) | 
|---|
返回存储函数的类型。
参数
%280%29
返回值
typeid(T)如果存储的函数有类型T,否则typeid(void)...
例外
noexcept规格:
noexcept
例
二次
#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二次
另见
| target | obtains a pointer to the stored target (public member function) | 
|---|
 © cppreference.com在CreativeCommonsAttribution下授权-ShareAlike未移植许可v3.0。
本文档系腾讯云开发者社区成员共同维护,如有问题请联系 cloudcommunity@tencent.com

