Boost logo

Boost :

Subject: Re: [boost] [functors] proposal
From: Piotr Wygocki (vwygos_at_[hidden])
Date: 2013-10-23 07:10:30


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);

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.

3) The And, Or, Xot and Not which were redundant with std::logical_or,
std::logical_and... Still there are missing nontemplate version, I added
them.

>
> Logical Xor ?
>

Semantically this is logical operator and it has equal rights with || or
&&. AFAIK the only reason that there is no such logical operator in c++ is
that it can be emulated by "!=".
Now Xor can be emulated by NotEqualTo.
Although I think it is better to have struct with clear semantic meaning,
I will stick to standarization committe point of view and remove Xor.

Regards,

Piotr

> New and useful functors are always welcome but please look at Phoenix
> first. If you feel you still have new functors maybe you can talk to the
> Phoenix developers to see if they will fit in Phoenix, or submit your
> library if there is enough interest by others.
>
>
>
>> Regards,
>>
>> Piotr
>>
>> ______________________________**_________________
>> Unsubscribe & other changes: http://lists.boost.org/**
>> mailman/listinfo.cgi/boost<http://lists.boost.org/mailman/listinfo.cgi/boost>
>>
>>
>
>
> ______________________________**_________________
> Unsubscribe & other changes: http://lists.boost.org/**
> mailman/listinfo.cgi/boost<http://lists.boost.org/mailman/listinfo.cgi/boost>
>


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