我有一个带有成员函数的类,该函数声明一个数组,数组的大小基于公式。
template <int SIZE>
class{
constexpr int lookup(const int) const
{
return n * n + n;
}
inline void func()
{
double array[lookup(SIZE)];
}
};
这给我vla错误。我认为它应该起作用,因为SIZE在编译时已解决,并且查找是一个constexpr。我知道以下方法会起作用:
template <int SIZE>
class{
inline void func()
{
constexpr int sz = SIZE * SIZE + SIZE;
double array[sz];
}
};
我想我只是想找出原因
很复杂...