News for hackers. Stuff that matters.
Re:C++ the Good Parts (2014) by makapuf on Thursday October 01, 2020 @04:04AM (#24648564)
IIUC you have this using `ranges` (which itself needs concepts as implemented). With it you can even do :

    for (int i : ints | std::views::filter(even) | std::views::transform(square)) {
        std::cout << i << ' ';
    }
notice the `for (int i:ints)` and the pipes filters.

EDIT: more specifically, you can use sort on a range now (source : https://cppreference.com):

    ranges::sort(s);
Re:C++ the Good Parts (2014) by innot on Thursday October 01, 2020 @05:45AM (#24649134)
The same functionality has been in boost [0] for quite a while. So, if you can't see the ugly iterators anymore, but have an outdated compiler, this is an option.

[0] https://www.boost.org/doc/libs/1_72_0/libs/range/doc/html/in...

Re:C++ the Good Parts (2014) by dgellow on Thursday October 01, 2020 @05:02AM (#24648911)
Wow, that pipe syntax is quite nice!

Documentation here: https://en.cppreference.com/w/cpp/ranges.

They are called "range adaptors" (weird naming IMHO).

Re:C++ the Good Parts (2014) by saagarjha on Thursday October 01, 2020 @05:44AM (#24649133)
They take a range and adapt it into a view, hence the name.
Re:C++ the Good Parts (2014) by account42 on Thursday October 01, 2020 @09:35AM (#24650626)
I wish they had just added the overloads to the std:: namespace though - breaking a few obscure cases would have been worth that.
Re:C++ the Good Parts (2014) by gumby on Thursday October 01, 2020 @01:43PM (#24653930)
> breaking a few obscure cases would have been worth that

The committee is very reluctant to break old code. That's one of the reasons the language as documented is so large.

That being said it's not clear to me what would have broken by putting sort(x) into std:: as you recommend.