The line:
Code:
sum += (gauss[x + 2][y + 2] = exp(-(x * x + y * y) / s) / s / M_PI);
cannot be compiled.

which says:
Code:
1>e:\projects\c++\edge_detect\edge_detect\Matrix.h(14): error C2059: syntax error : '['
1>          e:\projects\c++\edge_detect\edge_detect\Matrix.h(17) : see reference to class template instantiation 'matrix<T,D0,D1>' being compiled

How can I access the following class by the [] or [][] operator and access the matrix by row or element?

Code:
template<typename T, int D0, int D1>
class matrix
{
public:
	matrix();
	matrix(const D3DXVECTOR2& m0, const D3DXVECTOR2& m1);
	matrix(const D3DXVECTOR3& m0, const D3DXVECTOR3& m1, const D3DXVECTOR3& m2);
	
	float[4]& operator[](int row) const;

	float m[4][4];
};
Code:
matrix<float, 5, 5> gaussian_kernel(float sigma) 
{
    matrix<float, 5, 5> gauss;
    float sum = 0, s = 2 * sigma * sigma;

    for (int x = -2; x <= 2; x++)
        for (int y = -2; y <= 2; y++)
            sum += (gauss[x + 2][y + 2] = exp(-(x * x + y * y) / s) / s / M_PI);

    for (auto& row : gauss)
        for (auto& x : row)
            x /= sum;

    return gauss;
}