Date: Thu, 14 Sep 2023 11:29:09 +0200
Thanks all for your answers. I obviously misread the description in
https://en.cppreference.com/w/cpp/ranges/filter_view (in other places the
overload for a projection is explicitly shown). Yes, this helps a lot and
solves one problem. However the original issue I was trying to fix recently
was this: https://godbolt.org/z/TW8P5xqxz. I use range-v3 as a polyfill for
the missing std::views::chunk_by, maybe this is the problem.
On Wed, 13 Sept 2023 at 20:10, Arthur O'Dwyer <arthur.j.odwyer_at_[hidden]>
wrote:
> On Wed, Sep 13, 2023 at 11:20 AM Grzegorz Sikorski via Std-Proposals <
> std-proposals_at_[hidden]> wrote:
>
>> I started to notice a pattern that appears in many places. Consider a
>> code like this:
>>
>> struct Button {
>> std::string name;
>> bool enabled;
>> };
>>
>> auto get_enabled(const auto& buttons) {
>> return std::ranges::views::filter([](const auto& button) { return
>> button.enabled; });
>> }
>>
>> What I find useful is to add something like
>> https://godbolt.org/z/7Y5bdeddd. Projection support could also be useful
>> in some other std::ranges::views namespace members.
>>
>
> Nit: Write `std::views::filter`, not `std::ranges::views::filter`.
> Core confusion: Are you asking for C++20 to support std::invoke'ing a
> member data pointer? Because it already does. Example:
> https://godbolt.org/z/sqjxG3dW5
> return std::views::filter(&Button::enabled);
>
> –Arthur
>
https://en.cppreference.com/w/cpp/ranges/filter_view (in other places the
overload for a projection is explicitly shown). Yes, this helps a lot and
solves one problem. However the original issue I was trying to fix recently
was this: https://godbolt.org/z/TW8P5xqxz. I use range-v3 as a polyfill for
the missing std::views::chunk_by, maybe this is the problem.
On Wed, 13 Sept 2023 at 20:10, Arthur O'Dwyer <arthur.j.odwyer_at_[hidden]>
wrote:
> On Wed, Sep 13, 2023 at 11:20 AM Grzegorz Sikorski via Std-Proposals <
> std-proposals_at_[hidden]> wrote:
>
>> I started to notice a pattern that appears in many places. Consider a
>> code like this:
>>
>> struct Button {
>> std::string name;
>> bool enabled;
>> };
>>
>> auto get_enabled(const auto& buttons) {
>> return std::ranges::views::filter([](const auto& button) { return
>> button.enabled; });
>> }
>>
>> What I find useful is to add something like
>> https://godbolt.org/z/7Y5bdeddd. Projection support could also be useful
>> in some other std::ranges::views namespace members.
>>
>
> Nit: Write `std::views::filter`, not `std::ranges::views::filter`.
> Core confusion: Are you asking for C++20 to support std::invoke'ing a
> member data pointer? Because it already does. Example:
> https://godbolt.org/z/sqjxG3dW5
> return std::views::filter(&Button::enabled);
>
> –Arthur
>
Received on 2023-09-14 09:29:21