A way to make your operator[] work is to implement it as follows:

template<typename T, int D0, int D1>
class matrix
{
public:
matrix() {};

T* operator[](int row) { return m[row]; }