static const
是否可以使用模板参数包中的值创建一个数组?我尝试了以下代码,但 gcc 4.8.1 给出“错误:参数包未扩展”
template<int... N>
struct ARRAY_OF_DIMS
{
static constexpr size_t NDIM = sizeof...(N);
static const int DIMS[NDIM];
};
template<int... N>
const int ARRAY_OF_DIMS<N>::DIMS[ARRAY_OF_DIMS<N>::NDIM] = { N... };