Boost logo

Boost :

Subject: Re: [boost] [functors] proposal
From: Vicente J. Botet Escriba (vicente.botet_at_[hidden])
Date: 2013-10-23 07:21:51


Le 23/10/13 13:10, Piotr Wygocki a écrit :
> Than you for your feedback!
>
>
>
>> Are you aware of Boost.Phoenix ( or its predecessor Boost.Lambda ) ? Also
>> some of the functors appear to duplicate functors in the C++ standard
>> library in functional.
>
> 1) This is good point, this functors are for this kind of people who like
> lambdas.
>
> Many of proposed functors are equivalent to very simple lambdas.
> For example:
> ArrayToFunction can be replaced in most cases replaced with
>
> auto arrayToFunction = [&](int i){ return v[i];};
>
> or
>
> auto arrayToFunction = phoenix::ref(v)[_1];
>
> In this case my proposal is to standarize this kind of popular usage:
> auto arrayToFunction = make_ArrayToFunctor(v);
Popularity is subjective.
> 2) There is another use case for people who like passing functors and need
> default arguments.
>
> For example my SkipFunctor does exactly the same job as phoenix::nothing.
> For example my RetrunFalseFunctor does exactly the same job as
> phoenix::val(true).
>
> Look at this use case:
>
> template <typename SomeAction = SkipFunctor, typename StopCondidtion =
> ReturnFalseFunctor>
> struct Algorithm {
>
> };
>
> AFAIK it cannot be replaced with phoenix construction because we do not
> have the type of the nothing functor.
> Particularly, note that decltype(phoenix::nothing) is not going to work.
>
> This is tiny difference but this play a big role in a code I write.
>
What about adding phoenix::true_/phoenix::false_?
>
>
Vicente


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