cpp_weekly icon indicating copy to clipboard operation
cpp_weekly copied to clipboard

std::ranges quickstart

Open lefticus opened this issue 3 years ago • 6 comments

  • cover normal algorithm adapters (ie find_if)
  • cover basics of using | for composing of range views
  • show string split utility
  • show constexpr

lefticus avatar Jul 23 '22 21:07 lefticus

It would be nice if you also talk about the lazy evaluation of some ranges algorithms and how that works. Also the performance benchmarks comparing them with normal STL algorithms.

zencatalyst avatar Aug 02 '22 16:08 zencatalyst

It would be important to mention range categories and how applying views may change them.

yog-muskrat avatar Aug 16 '22 09:08 yog-muskrat

It would be important to mention range categories and how applying views may change them.

Can you elaborate? I don't see range categories discussed in the standard. I'm not sure where to look for that info.

lefticus avatar Aug 16 '22 16:08 lefticus

I think they mean the refinement of std::ranges::range modeled by views depending on the characteristics of the ranges piped into them. Those can be gleamed from the iterator_concept member of the iterator of range factories and adaptors. Like https://eel.is/c++draft/ranges#range.iota.iterator-1.

JohelEGP avatar Aug 16 '22 16:08 JohelEGP

Yes, I was talking about the range concepts, like std::ranges::input_range, std::ranges::sized_range etc.
Some view adapters will change the category of the resulting range. Like filter here.
This may sometimes lead to unexpected compile errors, or performance loss. For example, the upcoming std::ranges::to has an overload, that works with std::ranges::sized_range, which allows it to reserve space in container. But with a std::ranges::forward_range (which we have after applying filter) it may make lots of allocations due to resizing.

yog-muskrat avatar Aug 16 '22 17:08 yog-muskrat

I'm going to keep this very high level, and refer people back to comments and notes here.

Here is the outline I will be using: https://compiler-explorer.com/z/98n3Tsjo7

lefticus avatar Aug 29 '22 19:08 lefticus

Available: https://youtu.be/sZy9XcGHmI4

lefticus avatar Sep 24 '22 15:09 lefticus