c++11知识点整理

1.静态断言

template <typename t, typename us int bit_copy(t& a,u& b){
static_assert(sizeof(b)==sizeof(a),"the parameters of bit_copy must have same width.");
};

Boost中使用模版来实现:https://www.cnblogs.com/xiayong123/archive/2012/10/02/3717053.html

也可以使用除0错误的方式来实现:

#define assert_static(e)\
do{\
enum{ assert_static=1/(e)};\
}while(0)

《深入理解C++11:C++新特性解析与应用》

猜你喜欢

转载自www.cnblogs.com/1yzq/p/13170103.html
今日推荐