C++ typeid获取类型信息
#include <iostream>
#include <typeinfo>
int main()
{
int i;
const std::type_info &info = typeid(int);
std::cout << "typeid " << info.name() << std::endl;
if(info == typeid(i));
{
std::cout << "do something" << std::endl;
}
return 0;
}
$ ./a.out
typeid i
do something