What Is a Range in C++?
summary
C++20 formalizes ranges as types with ranges::begin and ranges::end, plus iterator categories that imply sized range, common range, or borrowed range semantics. Universal references are recommended for range parameters to avoid dangling iterators or hidden moves. Views are lazy code that can own or borrow data (owning_view vs ref view) and can make begin O(n) (filter) or drop an element from input streams (istream_view consumes the fourth value in the example). Sentinels allow faster loops; an unreachable_sentinel enables compile‑time optimization.
AI-written summary · about
chapters (10)
- 0:00Introduction
- 3:15Promoting books and content
- 10:26Range definition in C++20
- 13:20Ranges as universal references
- 25:07Understanding views
- 33:16Input ranges quirks
- 37:33Size ranges limits
- 43:14Common ranges and sentinels
- 49:11Summary of key concepts
- 50:35Q&A
related talks
58mMore C++ Ranges Please
01h 13mFrom Iterators to Ranges — the Upcoming Evolution of the Standard Library
56m“Range-Based Text Formatting For a Future Range-Based Standard Library”
59mWhat's New In The C++14 Library
01h 20mWhat Classes We Design and How
01h 34mC++11/14 at Scale - What Have We Learned?
58mModern C++ Design (part 2 of 2)
01h 00m“Evolving array_view and string_view for safe C++ code"
