C++20 Ranges in Practice
summary
C++20 Ranges get applied to three concrete problems: finding min (with GCC 10 support), summing squares (replacing eager transform+accumulate with a views::transform pipeline to reduce two passes to one), and string trimming (compose drop_while and reverse into adapters, expose them as inline constexpr adapters that return views and convert to std::string via ranges-next). Algorithms that would return iterators yield ranges::dangling for rvalue non‑borrowed ranges; solution is views::all or specialize enable_borrowed_range. A custom range‑aware accumulate with projection and range overloads compiles and behaves as expected.
AI-written summary · about
chapters (42)
- 0:00Introduction
- 1:45Outline
- 2:18Least Element
- 2:30Overview
- 3:43Problem Statement
- 4:26Standard Min Elements
- 8:58RValue Container
- 10:08Dereference Error
- 12:01String views
- 12:31Temporary string views
- 13:14Enable borrowed range
- 13:55Find
- 14:39Borrowing Ranges
- 15:23Views
- 18:38borrowed Ranges
- 19:33range adapters
- 20:21examples
- 23:44water
- 24:22transform
- 27:33numeric
- 29:01accumulate
- 32:48new function
- 33:33overload of accumulate
- 34:44call range accumulate on view
- 36:02projection
- 38:18square function
- 41:23trimstra
- 42:39sandersstring
- 44:28Ranges II
- 45:28Ranges Next
- 47:16Function Template
- 48:16White Space
- 48:58Drop While
- 50:20DropLastWhile
- 51:23Reverse
- 52:01Trim
- 52:58TrimFront
- 54:02Trimback
- 54:18Compose
- 57:01DropWhile
- 57:28Inline variables
- 58:34Trimming
related talks
01h 02mC++20 Ranges in Practice
01h 34mAn Overview of Standard Ranges
01h 01mFrom STL to Ranges: Using Ranges Effectively
01h 01mAn Overview of Standard Ranges
01h 09mMissing (and future?) C++ Range Concepts
01h 25mC++23 Ranges: Conceptual Changes and Useful Practicalities
57mRange Algorithms, Views and Actions: A Comprehensive Guide
01h 36mC++ Standard Views
