Boost logo

Boost :

From: Sergey Shandar (sergey_at_[hidden])
Date: 2007-11-28 19:09:37


shunsuke wrote:
> Sergey Shandar wrote:
>
>> 3. I found this one today:
>>
>> template<class T>
>> operator T &() const
>> throw(typename ::boost::disable_if< ::boost::is_same<T, MyClass
>> const> >::type *)
>>
>
> You've solved the millenium problem! :-)
>
> gcc3.4.5 and 4.1.2 seem to work fine.
> Thanks!
>
>
>
According to the standard, the code should not work.

14.8.2.2

    - All references in the function type of the function template to the
corresponding template parameters are replaced by the specified template
argument values. If a substitution in a template parameter or in the function
type of the function template results in an invalid type, type deduction fails.
[Note: *The equivalent substitution in exception specifications is done only
when the function is instantiated, at which point a program is ill-formed if
the substitution results in an invalid type.*] Type deduction may fail for the
following reasons:

However, it works on GCC. So, the workaround uses just another bug in
GCC :-)


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk