Quantcast
Channel: CSDN博客推荐文章
Viewing all articles
Browse latest Browse all 35570

【Boost】利用boost::typeid来获取变量的类型

$
0
0
class A
{
public:
	A(){};
	virtual ~A(){};
protected:

private:

};

struct B
{
	int a;
	long b;
};

void test_typeid()
{
	using namespace boost;

	int_fast_t<char>::fast a;			//char 类型的最快类型
	std::cout << typeid(a).name() << std::endl;

	int_fast_t<int>::fast b;			//int 类型的最快类型
	std::cout << typeid(b).name() << std::endl;

	int_fast_t<uint16_t>::fast c;		//uint16 类型的最快类型
	std::cout << typeid(c).name() << std::endl;

	A aa;
	B bb;
	std::cout << typeid(aa).name() << std::endl;
	std::cout << typeid(bb).name() << std::endl;
}
运行结果:
char
int
unsigned short
class A
struct B


作者:huang_xw 发表于2012-12-29 21:28:57 原文链接
阅读:48 评论:0 查看评论

Viewing all articles
Browse latest Browse all 35570

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>