Space Invaders: The C++20 Spaceship Operator is Upon Us
summary
Explains what breaks when flipping -std=c++20 on real code and why the compiler's rewriting rules can introduce infinite swap or ambiguity with implicit conversions; shows how defaulted and hand‑written three‑way operators interact, when the compiler generates six operators and when only four appear, and how to pick return types using comparison categories (strong/weak/partial) and std::common_comparison_category; gives concrete fixes (remove free ops, force member calls, add conversions) and shows examples that compile and fail so you know what to change.
AI-written summary · about
chapters (18)
- 0:00C++20 spaceship operator intro
- 1:55Sorting siblings in music DB
- 3:20Equality and relational ops
- 5:46Symmetry issues with hidden friends
- 9:19Operator symmetry C++20 rewrites
- 12:14Spaceship operator build breaks
- 16:09Defaulted spaceship operator basics
- 18:20Return type and comparison cats
- 23:20Non-defaulted spaceship operator
- 27:57Equivalence vs equality
- 30:30Ordering: strong weak partial
- 34:30Return type conflicts handling
- 38:27Doubles and ordering support
- 39:35Generic code and comparison cats
- 41:22Relational and inequality rewrites
- 45:48Concepts with three-way comparison
- 48:46Inheritance and defaulted spaceship
- 50:52Summary and closing
related talks
01h 02m“Operator Overloading: History, Principles and Practice”
01h 01mMoving to C++20 for Fun, Beauty... and Results!
58mC++17 in Practice - The good and the ugly
01h 03m“Programming with C++ Constraints: Background, Utility, and Gotchas"
01h 27mC++20 Templates - the Next Level: Concepts and More
58mUsing C++20's Three-way Comparison <=>
42mThe Nightmare of Move Semantics for Trivial C++ Classes
07mISO/IEC 14882
