C++ Logo


Advanced search

Re: Python-style comprehensive containers

From: Jason McKesson <jmckesson_at_[hidden]>
Date: Wed, 16 Jun 2021 14:50:25 -0400
On Wed, Jun 16, 2021 at 7:54 AM Phil Bouchard via Std-Proposals
<std-proposals_at_[hidden]> wrote:
> Greetings,
> 1) I admit code is quite clean using Python-style comprehensive containers. So by looking around I know there is the following already available:
> https://www.codeproject.com/Tips/5276120/Multi-Container-List-Comprehension-in-Cplusplus
> 2) But I'm sure there is a way to mix that with the new pipe operator to make it even cleaner:

There is no "new pipe operator" in the standard (as far as I'm aware).
The pipe operator is the normal, existing pipe operator from the days
of C++98.

There are overloads of this operator for ranges, but they don't
magically create syntax. They're just regular operator overloading.
And operator overloading can't make "each(x, x*x)" behave in any way
differently from how it would work on its own.

Received on 2021-06-16 13:50:40