[bug] Template friends, namespace and instantiation
Martin von Loewis
martin@mira.isdn.cs.tu-berlin.de
Wed Dec 9 03:08:00 GMT 1998
> I can't get this to work. It seems that there is a problem when
> overloading a friend function which is inside a namespace.
[...]
> namespace Test {
> template <class T> void resizeG(Vector<T>&, int ) { cout << "A" ;}
>
> template <>
> void resizeG(Vector<Point<float,3> >& , int ) { cout << "B" ; }
> }
>
> using namespace Test ;
> template void resizeG<Point<float,3> >(Vector<Point<float,3> >& , int ) ;
You did not mention what compiler you are using. I get (with
egcs-2.92.21):
nameFriend.cc:13: explicit instantiation of `void resizeG<Point<float,3>>(class Test::Vector<Point<float,3> > &, int)' after
nameFriend.cc:8: explicit specialization here
which is different from the message you get.
I believe your code is wrong. First, you declare a specialization. You
cannot have an explicit instantiation after you had the specialization.
What's more, there is a requirement that these things happen in the
namespace where the template was declared. I'm not sure whether this
restriction applies to specializations only, or to instantiations as
well.
Regards,
Martin
More information about the Gcc-bugs
mailing list