Archives
D Programming
DD.gnu digitalmars.D digitalmars.D.bugs digitalmars.D.dtl digitalmars.D.dwt digitalmars.D.announce digitalmars.D.learn digitalmars.D.debugger C/C++ Programming
c++c++.announce c++.atl c++.beta c++.chat c++.command-line c++.dos c++.dos.16-bits c++.dos.32-bits c++.idde c++.mfc c++.rtl c++.stl c++.stl.hp c++.stl.port c++.stl.sgi c++.stlsoft c++.windows c++.windows.16-bits c++.windows.32-bits c++.wxwindows digitalmars.empire digitalmars.DMDScript |
c++ - Internal error: exp2 121
/* matrix.cpp */ #include <iostream.h> template <class T, int n, int m> class Matrix { T v[n][m]; public: Matrix() { cout << "Matrix<T,n,m>" << endl; }; template <class TT, int nn, int mm> friend Matrix<TT,nn,mm> operator+(const Matrix<TT,nn,mm> &, const Matrix<TT,nn,mm> &); }; template <class T, int n, int m> Matrix<T,n,m> operator+(const Matrix<T,n,m> &x, const Matrix<T,n,m> &y) { cout << "operator+<T,n,m>" << endl; Matrix<T,n,m> r; for (int i = 0; i < n; ++i) for (int j = 0; j < m; ++j) r.v[i][j] = x.v[i][j] + y.v[i][j]; return r; } template <class T> class Matrix<T, 3, 3> { T v[3][3]; public: Matrix() { cout << "Matrix<T,3,3>" << endl; }; template <class TT> friend Matrix<TT,3,3> operator+(const Matrix<TT,3,3> &, const Matrix<TT,3,3> &); }; template <class T> Matrix<T,3,3> operator+(const Matrix<T,3,3> &x, const Matrix<T,3,3> &y) { cout << "operator+<T,3,3>" << endl; Matrix<T,3,3> r; r.v[0][0] = x.v[0][0] + y.v[0][0]; r.v[0][1] = x.v[0][1] + y.v[0][1]; r.v[0][2] = x.v[0][2] + y.v[0][2]; r.v[1][0] = x.v[1][0] + y.v[1][0]; r.v[1][1] = x.v[1][1] + y.v[1][1]; r.v[1][2] = x.v[1][2] + y.v[1][2]; r.v[2][0] = x.v[2][0] + y.v[2][0]; r.v[2][1] = x.v[2][1] + y.v[2][1]; r.v[2][2] = x.v[2][2] + y.v[2][2]; return r; } int main(void) { Matrix<int,3,3> m; m + m; return 0; } While compiled with dmc 8.29 (STLport STL not installed): m + m; ^ matrix2.cpp(57) : Error: ambiguous reference to symbol Had: operator +(const Matrix<>&,const Matrix<>&) and: operator +(const Matrix<>&,const Matrix<>&) Internal error: exp2 121 --- errorlevel 1 Sep 19 2002
I'll have a look at it. Thanks. -Walter Sep 19 2002
This is fixed now in the beta www.digitalmars.com/download/freecompiler.html But, it will still be necessary to make sure the parameter spelling in the template-parameter-list in the friend declaration matches the corresponding definition. -Walter "Iliya Peregoudov" <iliyap mail.ru> wrote in message news:3D899630.3523 mail.ru.../* matrix.cpp */ #include <iostream.h> template <class T, int n, int m> class Matrix { T v[n][m]; public: Matrix() { cout << "Matrix<T,n,m>" << endl; }; template <class TT, int nn, int mm> friend Matrix<TT,nn,mm> operator+(const Matrix<TT,nn,mm> &, const Matrix<TT,nn,mm> &); }; template <class T, int n, int m> Matrix<T,n,m> operator+(const Matrix<T,n,m> &x, const Matrix<T,n,m> &y) { cout << "operator+<T,n,m>" << endl; Matrix<T,n,m> r; for (int i = 0; i < n; ++i) for (int j = 0; j < m; ++j) r.v[i][j] = x.v[i][j] + y.v[i][j]; return r; } template <class T> class Matrix<T, 3, 3> { T v[3][3]; public: Matrix() { cout << "Matrix<T,3,3>" << endl; }; template <class TT> friend Matrix<TT,3,3> operator+(const Matrix<TT,3,3> &, const Matrix<TT,3,3> &); }; template <class T> Matrix<T,3,3> operator+(const Matrix<T,3,3> &x, const Matrix<T,3,3> &y) { cout << "operator+<T,3,3>" << endl; Matrix<T,3,3> r; r.v[0][0] = x.v[0][0] + y.v[0][0]; r.v[0][1] = x.v[0][1] + y.v[0][1]; r.v[0][2] = x.v[0][2] + y.v[0][2]; r.v[1][0] = x.v[1][0] + y.v[1][0]; r.v[1][1] = x.v[1][1] + y.v[1][1]; r.v[1][2] = x.v[1][2] + y.v[1][2]; r.v[2][0] = x.v[2][0] + y.v[2][0]; r.v[2][1] = x.v[2][1] + y.v[2][1]; r.v[2][2] = x.v[2][2] + y.v[2][2]; return r; } int main(void) { Matrix<int,3,3> m; m + m; return 0; } While compiled with dmc 8.29 (STLport STL not installed): m + m; ^ matrix2.cpp(57) : Error: ambiguous reference to symbol Had: operator +(const Matrix<>&,const Matrix<>&) and: operator +(const Matrix<>&,const Matrix<>&) Internal error: exp2 121 --- errorlevel 1 Sep 20 2002
Walter wrote:This is fixed now in the beta www.digitalmars.com/download/freecompiler.html But, it will still be necessary to make sure the parameter spelling in the template-parameter-list in the friend declaration matches the corresponding definition. Sep 21 2002
Iliya Peregoudov wrote:This beta (scppn.exe, 09/20/2002) compiles previous code but crashes with the following code that doesn't use specializations at all! Sep 21 2002
Ok, I posted the fix for this. -Walter "Iliya Peregoudov" <iliyap mail.ru> wrote in message news:3D8C47BA.1010805 mail.ru...Walter wrote:This is fixed now in the beta Sep 21 2002
Walter wrote:Ok, I posted the fix for this. -Walter Sep 23 2002
|