Daily bit(e) of C++

Share this post

Daily bit(e) of C++ | std::ranges::subrange

simontoth.substack.com

Discover more from Daily bit(e) of C++

Random C++ knowledge organized in arbitrary order.
Over 1,000 subscribers
Continue reading
Sign in

Daily bit(e) of C++ | std::ranges::subrange

Daily bit(e) of C++ #321, The convenience adapter for adapting another range, or a pair of an iterator and a sentinel into a range: std::ranges::subrange.

Šimon Tóth
Nov 18, 2023
1
Share this post

Daily bit(e) of C++ | std::ranges::subrange

simontoth.substack.com
Share

The std::ranges::subrange is a convenience wrapper that can construct a range from another range or a pair of an iterator and a sentinel.

To maintain the sized property of a range, the size can be passed as an additional argument.

One use case for std::ranges::subrange is to adapt algorithms and methods that return a pair of iterators.

Click to open in Compiler Explorer.

Leave a comment

Thanks for reading Daily bit(e) of C++! Subscribe for free to receive new posts and support my work.

1
Share this post

Daily bit(e) of C++ | std::ranges::subrange

simontoth.substack.com
Share
Comments
Top
New
Community

No posts

Ready for more?

© 2023 Šimon Tóth
Privacy ∙ Terms ∙ Collection notice
Start WritingGet the app
Substack is the home for great writing