Boost logo

Boost :

From: Tobias Schwinger (tschwinger_at_[hidden])
Date: 2007-01-08 16:46:38


Doug Gregor wrote:
<snip>
>>> Now, in C++0x, the metaprogramming-based implementation and
>>> specification of result_of is going to disappear in favor of
>>> decltype.
>> We can remove that nested result class template, then...
>
> Right! But we don't get SFINAE-like behavior.
>
>>> With a decltype-based implementation, the code above would
>>> be ill-formed, so I think the right answer is "do the same thing that
>>> the decltype implementation would do."
>> ... but I guess we might be able to use that very language
>> extension to
>> detect whether a function object has a call operator that suits given
>> argument types.
>
> This has gone back-and-forth many times. At present, the expression
> inside decltype won't have SFINAE capabilities, just like sizeof
> doesn't work with SFINAE now.
>

That's not what I meant. I'll try with code:

     struct reserved { };

     template<class FuncObj> struct tester
         : FuncObj
     {
         using FuncObj::operator();
         reserved operator()(...) const;
         // [...]
     };

     // Check whether the type of the expression 'some_tester(a0...aN)'
     // is 'reserved' in a traits template.

I guess that would require the function object to be copy-constructible,
but that doesn't seem like a show stopper to me...

Regards,
Tobias


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