【发布时间】:2015-11-01 09:24:57
【问题描述】:
为什么我可以这样做:
constexpr auto i_can() {
int a = 8;
a = 9;
//...
}
但我不能这样做:
constexpr auto i_cannot() {
std::array<int, 10> arr{};
//I cannot
arr[5] = 9;
}
我的问题是:
- 如果我可以改变
int,为什么我不能改变数组内部的int? - 这是语言限制 (C++14) 还是标准库规范问题?
reference std::array<T, N>::operator[](size_t)当前不是constexpr。
【问题讨论】: