I have a compile time tensor class. Now i would like to implement index access like this:
std::array<std::array<std::array<int, 3>, 2>, 1> myTensor;
template <class... Indices>
auto get(Indices... indices) {
return myTensor[indices][...];
}
int main() {
myTensor[0][1][2] = 3;
std::cout << get(0, 1, 2) << std::endl;
}
But this sadly does not compile. Does anyone have an idea of how i could implement this? It also needs to work when my tensor is const. I would also be fine using tuple instead of variadic template. I can use the most modern compiler/cpp standard if needed.