Effective Ranges: A Tutorial for Using C++2x Ranges
summary
Hands-on C++20/23 coverage that shows concrete code (links to Godbolt) and what changes: use std::ranges algorithms instead of begin/end, pipeable views and adapters for lazy composition, and the new collection builders like range-based constructors to materialize results. Demos include std::print, sort-on-ranges, find_last, cartesian_product, zip, span, join+filter, and a sum-of-squares pipeline using iota/take and fold_left, with notes on caching, const-ref pitfalls, and performance (no needless moves).
AI-written summary · about
chapters (12)
- 0:00Introduction
- 10:20Ranges in C++2x
- 14:18Range algorithms differences
- 21:31Views and lazy evaluation
- 24:54Range adapters and pipe syntax
- 30:09Standard range views
- 35:12Span as contiguous view
- 38:25Converting views to collections
- 43:30Custom views in C++23
- 45:35Practical examples
- 49:02Best practices
- 50:53Q&A
related talks
01h 06mConquering C++20 Ranges
01h 00mMissing (and future?) C++ range concepts
01h 05mBetter C++ ranges
01h 04mRange adaptors - 5 years after C++20
40mRanges and Iterators for Numerical Problems
56mThrowing Tools at Ranges
55mC++ Cache Friendly Data + Functional + Ranges = ❤️
01h 05mThe Imperatives Must Go!
