Boost logo

Boost :

Subject: Re: [boost] [Fit] upcoming formal review for Boost.Fit
From: paul Fultz (pfultz2_at_[hidden])
Date: 2016-03-03 13:45:06


> On Thursday, March 3, 2016 12:36 PM, Sam Kellett <samkellett_at_[hidden]> wrote:
> > On 3 March 2016 at 17:39, paul Fultz <pfultz2_at_[hidden]> wrote:
>>
>> > On Wednesday, March 2, 2016 2:56 PM, Bjorn Reese <
>> breese_at_[hidden]> wrote:
>> > > On 02/27/2016 05:16 PM, Vicente J. Botet Escriba wrote:
>> >
>> >> Documentation:http://pfultz2.github.io/Fit/doc/html/
>> >
>> > In More Examples / Projections there is this example:
>> >
>> > std::sort(std::begin(people), std::end(people),
>> > by(&Person::year_of_birth, _ < _));
>> >
>> > That strikes me as a very terse syntax, where the reader could easily
>> > miss the fact that two values are being compared. Have you considered
>>
>> > the use of placeholders like _1 and _2 instead?
>>
>> They are already supported. The anonymous placeholders are only there to
>> describe an operator(they are not bind expressions). It could also be
>> written
>> like this as well:
>>
>> std::sort(std::begin(people), std::end(people),
>> by(&Person::year_of_birth, std::less_than<>()));
>>
>> The clarity of two parameters being passed to `std::less_than` is just as
>> clear as when using the anonymous placeholders. The advantage of writing
>>
>> `_ < _` is that it is generic, SFINAE and constexpr friendly.
>>
>
> so if i understand correctly, that means that this work:
>
>
> std::sort(std::begin(people), std::end(people), by(&Person::year_of_birth,
> _2 < _1);
>

> as one way to reverse sort. right?

Yes.

Paul


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