This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: explicit function template qualification


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/



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]