【发布时间】:2020-02-19 05:39:15
【问题描述】:
我遇到了一个奇怪的案例。
// this does not work, and reports:
// constexpr variable 'b' must be initialized by a constant expression
int main() {
const double a = 1.0;
constexpr double b = a;
std::cout << b << std::endl;
}
// this works...
int main() {
const int a = 1;
constexpr int b = a;
std::cout << b << std::endl;
}
double 有什么特别之处,所以它不能让constexpr 工作吗?
【问题讨论】:
-
看到这个question。
标签: c++ c++11 integer double constexpr