This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: explicit function template qualification
- To: Jason Merrill <jason at cygnus dot com>
- Subject: Re: explicit function template qualification
- From: Mumit Khan <khan at xraylith dot wisc dot edu>
- Date: Thu, 02 Oct 1997 11:25:19 -0500
- cc: egcs at cygnus dot com, g++ at cygnus dot com
Jason Merrill <jason@cygnus.com> writes:
> I just checked in a patch from Mark to implement explicit specification of
> template parameters to function templates.
>
> 2) Guiding decls are no longer supported. So code like
Ouch! This unfortunately breaks lots of my code (easily fixable however)
and a few others floating around the net (eg., octave breaks miserably).
But that's how the language works ...
Jason, I tried out your example with operator==<>:
template <class T> int
operator== (const T&, const T&)
{
return 0;
}
struct A {
A (int) { }
friend int operator==<> (const A&, const A&);
};
main ()
{
A a (1);
return a == 1; // << rhs doesn't match A(int)!
}
And I get the following with egcs-970929 (haven't built the latest fsf
snapshot, so can't comment on that) on i386-linux-gnulibc1:
% c++ -c tmpl3.cc
tmpl3.cc: In function `int main()':
tmpl3.cc:15: no match for `A & == int'
Looks like the user-defined conversions are ignored (A::A(int)). If I now
use the following, everything works out.
return a == A(1); // << force rhs match A(int)!
I'm hoping this is just a bug, and not by design. fyi, I've already
reported something similar for 970929 where the implicit conversions are
also botched (eg., ``complex<double> + 1'' doesn't work, but
``complex<double> + 1.0'' works).
Regards,
Mumit -- khan@xraylith.wisc.edu
http://www.xraylith.wisc.edu/~khan/