Boost logo

Boost Users :

From: Ian McCulloch (ianmcc_at_[hidden])
Date: 2005-03-17 18:28:05


Peter Dimov wrote:

> Ian McCulloch wrote:
>> Thanks Peter, I think I understand how it works now. Unfortunately,
>> the lack of SFINAE is a real showstopper for me. I want to write
>> functions like
>>
>> template <typename T>
>> typename result_of<negate(T)>::type
>> operator-(T const& x)
>> {
>> return negate()(x);
>> }
>>
>> but the lack of SFINAE here makes boost::result_of essentially
>> useless for this.
>
> Yes, I've encountered this too. The problem is in the unconditional
> instantiation of the nested ::result<>. Since we don't have a reliable way
> to detect a nested template yet (requires core language change), this
> can't be fixed except by removing the ::result<> logic altogether and
> relying on specializations instead, as in the example I gave.

I don't get it: can't you detect whether nested::result<nested(T)>::type
exists? As long as the primary template of nested::result is defined as an
empty struct this should work fine(?).

>
> This won't help us in general, though. result_of is not supposed to
> support SFINAE, because it may be implemented with __typeof or __decltype
> internally.

Do you mean that a substitution failure in a typeof or decltype expression
*is* an error? Ouch!

Cheers,
Ian


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net