转发声明一个 constexpr 数组模板

问题描述 投票:0回答:0

类似的问题已经有人问过。

但是,我想了解为什么对于数组,下面的第一行不编译而第二行编译:

template<int N> constexpr float x[2]; // ERROR - var not initialized.
template<int N> constexpr float y[N];

// Can now specialize, e.g.:
template<> constexpr float y<2>[2] = {0.0f, 1.0f};
c++20 constexpr
© www.soinside.com 2019 - 2024. All rights reserved.