function::target_type
取得可呼叫的物件上,輸入資訊。
const std::type_info& target_type() const;
備註
成員函式會傳回typeid(void)如果*this是空的否則它會傳回typeid(T),其中T的目標物件型別。
範例
// std_tr1__functional__function_target_type.cpp
// compile with: /EHsc
#include <functional>
#include <iostream>
int neg(int val)
{
return (-val);
}
int main()
{
std::function<int (int)> fn0(neg);
std::cout << std::boolalpha << "empty == " << !fn0 << std::endl;
std::cout << "type == " << fn0.target_type().name() << std::endl;
std::function<int (int)> fn1;
std::cout << std::boolalpha << "empty == " << !fn1 << std::endl;
std::cout << "type == " << fn1.target_type().name() << std::endl;
return (0);
}
需求
標頭: <functional>
Namespace: 標準