From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jason Merrill To: egcs@cygnus.com, g++@cygnus.com Subject: explicit function template qualification Date: Sun, 28 Sep 1997 13:12:00 -0000 Message-id: <199709282011.NAA15473@yorick.cygnus.com> X-SW-Source: 1997-09/msg01060.html I just checked in a patch from Mark to implement explicit specification of template parameters to function templates. In other words, template T min (T a, T b) { return a(5, 8.0); } A couple of side effects that may bite you: 1) Mangling of template instantiations now depends on the template they came from; in particular, template instantiations are no longer mangled like a non-template function. 2) Guiding decls are no longer supported. So code like struct A { friend int operator== (const A&, const A&); A (int) { } }; template int operator== (const T&, const T&) { return 0; } main () { A a (1); return a == 1; } will now fail with an undefined symbol, because the friend refers to a normal function, not a template instantiation. The complex and iomanip classes in libstdc++, for instance, had to be changed. If the friend really needs to be a friend, you can add <> after the declarator (so operator==<>, in this example) to make it refer to a template instantiation. If you had the friend decl in a template for overloading purposes, you're out of luck; you'll need to define any forwarding functions. This is the way the language works now, sorry. Both of these side effects can be reverted with -fguiding-decls, but that will cause mangling clashes in some cases of explicit qualification, and should not be used with new code. Thanks again, Mark! Jason