I have an N-dimensional Matrix class that has a constructor with a parameter pack. Is it possible to set the size of the std::array
member variable depending on the values in the parameter pack? As far as I understand the values in the parameter pack should be known at compile time.
template<size_t N>
class Matrix {
public:
template<typename... Exts>
Matrix(Exts... exts) : dimSizes{exts...} { }
private:
std::array<size_t, N> dimSizes;
std::array<float, N> data;
// e.g something like this: std::array<float, dimSizes[0]> data;
};
int main(void) {
Matrix<3> mat(2, 3, 2);
return 0;
}
Aucun commentaire:
Enregistrer un commentaire