代码
代码
#include <iostream>
#include <string>
#include <typeinfo>
#include <vector>
#include <map>
#include <queue>
#include <cxxabi.h>
template<typename T>
char *type(T t)
{
char *name = abi::__cxa_demangle(typeid(t).name(), NULL, NULL, NULL);
return (char *)(name ? name : typeid(t).name());
}
#define CoutType(x) std::cout << type(x)<< std::endl
using namespace std;
string str;
wstring wstr;
vector<int> veci;
map<double,int> mpdi;
queue<int> quei;
int int_i;
double double_d;
char char_c;
bool bool_b;
int main(){
CoutType(str);
CoutType(wstr);
CoutType(veci);
CoutType(mpdi);
CoutType(quei);
CoutType(int_i);
CoutType(double_d);
CoutType(char_c);
CoutType(bool_b);
}
执行结果
std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >
std::__cxx11::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >
std::vector<int, std::allocator<int> >
std::map<double, int, std::less<double>, std::allocator<std::pair<double const, int> > >
std::queue<int, std::deque<int, std::allocator<int> > >
int
double
char
bool