C++20 - My Favourite Code Examples
summary
C++20 examples show concrete code: generic add() overloads resolved with concepts + constraints instead of SFINAE, ranges and views used to pipe, take, drop and transform collections, and jthread + stop_token plus atomic_ref for thread-safe parallel initialization. The chrono calendar/timezone types let code iterate months safely or choose last-day semantics. Demonstrations expose surprising failure modes: ambiguous overloads, view begin caching causing data races, and a runtime error from misused drop — with exact fixes and tradeoffs.
AI-written summary · about
chapters (16)
- 0:00C++20 favorites intro
- 1:55Simplified function templates
- 4:01Overload resolution with concepts
- 8:01Requirements vs constraints
- 13:16When to use concepts
- 16:57Concepts for error messages
- 19:52Ranges and views
- 23:47Sentinels in ranges
- 27:21Universal references
- 35:24Thread safety with jthread
- 41:09Chrono extensions
- 44:47Combining C++20 features
- 46:35Sales data with ranges
- 50:36Runtime errors in views
- 55:12Caching in views
- 57:18C++20 summary








