#include<boost/type_index.hpp>
using namespace std;
template<typename T>
void f(T&& t)
{
cout << "---------------" << endl;
using boost::typeindex::type_id_with_cvr;
cout << type_id_with_cvr<T>().pretty_name() << endl;
cout << type_id_with_cvr<decltype(t)>().pretty_name() << endl;
}
int main()
{
using boost::typeindex::type_id_with_cvr;
cout << type_id_with_cvr<decltype(sizeof(3))>().pretty_name() << endl;
system("pause");
return 0;
}
c++借助boost库的资源测试对象类型的代码示例
本文展示了如何在C++中使用Boost.TypeIndex库来获取和打印类型信息,包括原始类型和表达式类型的结果。


被折叠的 条评论
为什么被折叠?



