Getting the number of elements in std::array at compile time

前端 未结 4 957
礼貌的吻别
礼貌的吻别 2021-02-06 23:45

Is the following a valid C++ code, and why not?

std::array a1;
std::array a2;

It doesn\'t compile

4条回答
  •  一生所求
    2021-02-07 00:00

    It is not static but it is a constexpr http://www.cplusplus.com/reference/array/array/size/
    EDIT: this may not be a bug, take a look at this Error using a constexpr as a template parameter within the same class

提交回复
热议问题