Re: [boost] [Fit] upcoming formal review for Boost.Fit
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?
On 3/03/2016 09:56, Bjorn Reese 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?
Being able to use arguments out of order or repeatedly is often useful as well.
On Wednesday, March 2, 2016 2:56 PM, Bjorn Reese
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. Paul
On 3 March 2016 at 17:39, paul Fultz
On Wednesday, March 2, 2016 2:56 PM, Bjorn Reese < breese@mail1.stofanet.dk> 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?
On Thursday, March 3, 2016 12:36 PM, Sam Kellett
wrote: On 3 March 2016 at 17:39, paul Fultz
wrote: On Wednesday, March 2, 2016 2:56 PM, Bjorn Reese < breese@mail1.stofanet.dk> 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
participants (4)
-
Bjorn Reese
-
Gavin Lambert
-
paul Fultz
-
Sam Kellett