https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86246

--- Comment #2 from Nathan Sidwell <nathan at gcc dot gnu.org> ---
This no longer ices.  and I am not sure the code is well formed.  The code is
explicitly naming a conversion operator 'obj.operator T()', which is not the
same as relying on the conversion mechanism of 'static_cast <T> (obj)'.  do we
perform the lookup at template-definition time (using 'T'), or do we defer to
instantiation time and use 'double'.

If you want to specialize 'operator T' for T == double, provide an explicit
specialization:

 template<>
 MyClass::operator double () const 
 {
    return 2;
 }

(this has to be outside the class definition, because thems the rules on
specializations).  That compiles without error.

The rules for when naming a conversion operator finds just set using those
names is not the clearest, and I could be wrong.  I know we get things like
'operator auto () const {return 1;} wrong -- that remains 'operator auto', it
doesn;t turn into 'operator int'.

Reply via email to