Proposal: Allow a narrow subset of std::views to replace base:: equivalents

10 views
Skip to first unread message

Jan Wilken Dörrie

unread,
5:34 AM (14 hours ago) 5:34 AM
to cxx, Daniel Cheng, Tamino Bauknecht, Thomas Sepez, Stefan Zager

Hi everyone,


I would like to propose moving a small, specific subset of std::views from Banned to Allowed.


Background Historically, std::views and range adaptors were banned due to concerns regarding compile-time overhead, optimization difficulties, and the subjective readability issues of chaining with operator|.


However, since we recently deployed a Clang plugin that actively bans the use of operator| for range adaptors, the pipe syntax won't compile anyway. By relying on direct function call syntax (e.g., std::views::reverse(range)), we naturally discourage deeply nested chaining, which mitigates the worst compile-time hits and readability concerns.


Motivation Currently, we are reimplementing quite a bit of the standard view machinery directly in base. Specifically, we maintain base::Zip, base::Reversed, and base::RangeAsRvalues. It would be significantly easier and reduce our maintenance burden to just use the std::views equivalents directly.


Proposal


  1. Update c++-features.md to explicitly allow the following specific views:

  2. Migrate existing usages of these base:: utilities to std::views:: and eventually deprecate the base:: versions.


If in the future folks find other utilities from <ranges> helpful, you are highly encouraged to propose them on the mailing list as separate proposals. For example, std::views::transform or std::views::enumerate also seem pretty useful.


Thoughts?


Best regards,

Jan


Nico Weber

unread,
10:09 AM (9 hours ago) 10:09 AM
to Jan Wilken Dörrie, cxx, Daniel Cheng, Tamino Bauknecht, Thomas Sepez, Stefan Zager
Do you have numbers on compile time cost? I imagine some of the cost comes from including headers?

--
You received this message because you are subscribed to the Google Groups "cxx" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cxx+uns...@chromium.org.
To view this discussion visit https://groups.google.com/a/chromium.org/d/msgid/cxx/CALB5StZ21Nx_Qc6Hye-9WLUry1yKVXNjWAkjqnRo-2%3DvQs0%2BRw%40mail.gmail.com.
Reply all
Reply to author
Forward
0 new messages