Date: Wed, 13 Sep 2023 14:10:36 -0400
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
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-13 18:10:50