|
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++ - spurious 'friend' causes internal error
In the code below a cut-and-paste error put a spurious 'friend' in a function
definition.
The compiler exits with "Internal error: template 1412" instead of an error
message.
#include <iostream.h>
template <typename T>
class pair {
T val1, val2;
public:
pair (T a, T b): val1(a), val2(b) {}
T first() {return val1;}
T second() {return val2;}
template <typename T>
friend ostream& operator << (ostream& os, pair<T> const& p);
};
// the 'friend' below is an error
template <typename T>
friend ostream& operator << (ostream& os, pair<T> const& p)
{
return os << p.val1 << ',' << p.val2;
}
int main()
{
pair<int> p(1,2);
cout << p << '\n';
}
Jun 08 2003
|