C++ Logo

std-proposals

Advanced search

[std-proposals] Add Projection Support for std::ranges::views

From: Grzegorz Sikorski <sikorski.grzegorz_at_[hidden]>
Date: Wed, 13 Sep 2023 14:51:37 +0200
Hello,

I am new to the std-proposals and I assume something like this has already
been considered in the past, but I wonder if it was rejected for any reason
or is it planned to address at some point?

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.

Greg

Received on 2023-09-13 12:51:47