This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
template function
- To: egcs-bugs at egcs dot cygnus dot com
- Subject: template function
- From: "Dr. Michael Albert" <albert at esther dot rad dot tju dot edu>
- Date: Mon, 31 May 1999 15:57:45 -0400 (EDT)
Dear Friend:
First let me say how much I appreciate Cygnus's work with the GNU
project and the effort of all of those involved.
I'm afraid today, though, I'm here to issue a bug report (forgive
me if I am mistaken, but to the best of my knowledge this code
is ANSI).
Thank you.
-Mike
Using egcs-2.91.66 19990314 (egcs-1.1.2 release) under Solaris2.5.1
--------------------------code-----------------------------------------
template<class T,int W, int H>
class XX{
public:
friend class YY;
class YY{};
};
template<class O, class T, const int W, const int H>
O& operator<<(O& o, XX<T,W,H>& xx)
{
XX<T,W,H>::YY yy;
return o;
}
int main(int argc, char *argv[])
{
int x;
XX<int,100,100> xx;
x << xx;
}
----------------------------error message--------------------------------
g++ -c nest.cc
nest.cc: In function `int & operator <<<int, int, 100, 100>(int &, class
XX<int,100,100> &)':
nest.cc:19: instantiated from here
nest.cc:11: type/value mismatch at argument 2 in template parameter list
for `template <class T, int const W, int const H> XX<T,W,H>'
nest.cc:11: expected a constant of type `int', got `int'
nest.cc:11: confused by earlier errors, bailing out
make: *** [nest.o] Error 1