C++编译期的类型测试

编译期的类型测试

一、使用模板特化机制

如比较两个类型是否一致:

VC8及以后版本支持了type traits机制:

add_const Class            // Makes const type from type.

add_cv Class               // Makes const/volatile type from type.

add_pointer Class          // Makes pointer to type from type.

add_reference Class        // Makes reference to type from type.

add_volatile Class         // Makes volatile type from type.

aligned_storage Class      // Makes suitably aligned type.

alignment_of Class         // Gets alignment of type.

common_type Class

conditional Class

decay Class

enable_if Class

extent Class               // Gets an array dimension.

has_nothrow_assign Class   // Tests whether the type does not throw on assign.

has_nothrow_constructor Class // Tests whether the type does not throw on default construction.

has_nothrow_copy Class     // Tests whether the type does not throw on copy construction.

has_nothrow_copy_constructor Class

has_nothrow_default_constructor Class

has_trivial_assign Class   // Tests whether the type has trivial assign.

has_trivial_constructor Class // Tests whether the type has trivial default constructor.

has_trivial_copy Class     // Tests whether the type has trivial copy constructor.

has_trivial_copy_constructor Class

has_trivial_default_constructor Class

has_trivial_destructor Class // Tests whether the type has trivial destructor.

has_virtual_destructor Class // Tests whether the type has virtual destructor.

is_abstract Class          // Tests whether the type is abstract class.

is_arithmetic Class        // Tests whether the type is arithmetic.

is_array Class            

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值