[bug] Template friends, namespace and instantiation
Lavoie Philippe
lavoie@zeus.genie.uottawa.ca
Tue Dec 8 19:54:00 GMT 1998
Hi,
I can't get this to work. It seems that there is a problem when
overloading a friend function which is inside a namespace. The problem
only shows up when you have multiple files (and using
-fno-implicit-templates). I'd like to use something beside no implicit
templates, but in my library, recompiling every templates takes too
much time.
I'll reduce the code to the problem area here
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 ) ;
This fails with
g++ -c nameFriend.cc
nameFriend.cc:13: no matching template for `resizeG<Point<float,3>>(::Test::::Test::Vector<Point<float,3> > &, int)' found
make: *** [nameFriend.o] Error 1
removing template <> makes the compilation go smoothly but then the
output is A and not B. What to do ?
Please help as this is very annoying (hopefully, it's not a bug, but
just me who can't initialize stuff properly).
Anyway, here is the full test code (It has to be in different source
files otherwise, the problem doesn't show up, that's why this is being
sent as a tar file)
Phil
-------------- next part --------------
A non-text attachment was scrubbed...
Name: nameFriend.tar
Type: application/x-tar
Size: 10240 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-bugs/attachments/19981208/313bbeaf/attachment.tar>
More information about the Gcc-bugs
mailing list