This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

templates and out-of-line functions


The following "silly" program doesn't compile. It works, though, if the 
hello function is inlined inside the class declaration.
The following errors are reported by g++ (linux redhat 6.2, i586)
gcc 2.95.2 and also the latest snapshot (egcs-20000501):

b1.cc:13: prototype for `void A<T, P>::hello (A<T, A<T, P>::NUM1> &)'
b1.cc:13: does not match any in class `A<T, P>'
b1.cc:7: candidate is: void A<T, P>::hello (A<T, A<T, P>::NUM1> &)
b1.cc:13: template definition of non-template `void A<T, P>::hello
b1.cc:13: (A<T, A<T, P>::NUM1> &)'

I don't see any difference between the error prototype and
the suggested candidate. Source code follows:

// --------------- b1.cc --

template <class T, int P=1>
class A {
   public:
      enum { NUM1, NUM2 };
      
      void hello(A<T, NUM1> & v);
};


template <class T, int P>
void A<T,P>::hello(A<T, A<T,P>::NUM1> & v)
{

}

void main()
{
   A<int,2> a;
   A<int, A<int,2>::NUM1 > b;
   a.hello(b);
}

// -----------------

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]