123456789101112131415161718192021222324
#include <cstddef> #include <array> template <typename T, size_t rank> class Tensor { public: Tensor() = default; explicit Tensor(const std::array<unsigned, rank>& shape); ~Tensor(); T& operator()(const std::array<unsigned, rank>& shape); T operator()(const std::array<unsigned, rank>& shape) const; template<typename... Indices> T& operator()(Indices... indices); // turns indices to array and calls the other overload template<typename... Indices> T operator()(Indices... indices) const; private: T* data; std::array<unsigned, rank> shape; size_t _size; };