Boost logo

Boost Users :

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


Arkadiy Vertleyb wrote:

> "Ian McCulloch" <ianmcc_at_[hidden]> wrote
>
>> 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. But I imagine it won't be difficult to make a new version based on
>> boost that would work.
>
> FWIW:
>
> template<class T>
> T make();
>
> template <class T>
> BOOST_TYPEOF_TPL(make<std::negate<T> >()(T()))
> operator-(T const& x)
> {
> return std::negate<T>()(x);
> }

This looks very attractive, and I'll probably und up using it somewhere; but
in the particular application I'm working on, something like result_of (but
allows SFINAE) will do fine. I guess its just a matter of what changes
I'll need to make when we get decltype. With the result_of approach I
could get rid of the nested result<> structs and/or result_of
specializations, with the BOOST_TYPEOF approach I could simplify the
forwarding function declarations. I'm not sure what is the better
tradeoff.

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