top | item 37538809

(no title)

BenFrantzDale | 2 years ago

For list comprehension, we have (C++23): `std::ranges::to<std::vector>(items | std::views::filter(shouldInclude) | std::views::transform(f))` it’s not quite `[f(x) for x in items if shouldInclude(x)]` but it’s the same idea.

discuss

order

nuancebydefault|2 years ago

To be honest, if that's the notation, i will not be very eager to jump on cpp23. That said, I admire people who's minds stay open for c++ improvements and make that effort.

logicchains|2 years ago

Well you could write it as

    to<vector>(items | filter(shouldInclude) | transform(f))
if you really want to, but generally C++ programmers prefer to be explicit and include the namespaces.

Tommstein|2 years ago

Sweet baby Jesus I thought that was a joke as I started reading it. Still not entirely sure.