C++11开始constexpr作为一种声明,为编译器提供了在编译期间确认结果的优化建议,满足部分编译期特性的需求
constexpr和const区别
int b=10;
const int a=b;
//运行成功
constexpr int c=b;
//编译器报错,b的值在编译期间不能确定
const int size1(){
return 100;}
constexpr int size2(){
return 100;}
C++11开始constexpr作为一种声明,为编译器提供了在编译期间确认结果的优化建议,满足部分编译期特性的需求
constexpr和const区别
int b=10;
const int a=b;
//运行成功
constexpr int c=b;
//编译器报错,b的值在编译期间不能确定
const int size1(){
return 100;}
constexpr int size2(){
return 100;}