#ifndef YAGE_MATH_MATRIX_HPP #define YAGE_MATH_MATRIX_HPP #include #include namespace yage { template class Matrix; namespace detail { template class Row { private: std::shared_ptr> parent_; int index_; public: Row(std::shared_ptr> parent, int index) : parent_(parent), index_(index) {} Type &operator[](int col) { return parent_->data_[index_*Cols+col]; } }; } // detail template class Matrix { friend class detail::Row; private: std::vector data_; public: Matrix() : data_(Rows*Cols) {} Matrix(int rows, int cols) : data_(rows*cols) {} detail::Row operator[](int row) { return detail::Row(std::make_shared>(*this), row); } }; } // yage #endif