新增关键字static_assert!
⽤用于编译时排错
static_assert((GREEKPI > 3.14) && (GREEKPI < 3.15), "GREEKPI is
inaccurate!”);
!
//类级:
template
struct Check {
static_assert(sizeof(int) <= sizeof(T), "T is not big enough!");
};
!
//⽅方法级:
template
Integral foo(Integral x, Integral y) {
static_assert(std::is_integral::value, "foo() parameter must
be an integral type.");
}