I have a class with a member function which declares an array whose size is based off a formula.
template <int SIZE>
class{
constexpr int lookup(const int) const
{
return n * n + n;
}
inline void func()
{
double array[lookup(SIZE)];
}
};
This gives me the vla error. I think it should work because SIZE is resolved at compile time, and lookup is a constexpr. I know the following will work:
template <int SIZE>
class{
inline void func()
{
constexpr int sz = SIZE * SIZE + SIZE;
double array[sz];
}
};
I guess I'm just trying to figure out why
Aucun commentaire:
Enregistrer un commentaire