This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: [bug] Template friends, namespace and instantiation
- To: lavoie at zeus dot genie dot uottawa dot ca
- Subject: Re: [bug] Template friends, namespace and instantiation
- From: Martin von Loewis <martin at mira dot isdn dot cs dot tu-berlin dot de>
- Date: Wed, 9 Dec 1998 09:43:45 +0100
- CC: egcs-bugs at cygnus dot com
- References: <199812082204.RAA08432@yoho.uottawa.ca>
> 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