F.21
summary
Guideline F.21 claims: to return multiple “out” values, return a struct rather than a tuple. Evidence: tuples permit accidental mixing of unrelated returned values and enable nonsensical comparisons, weakening the static type system. Tools shown: pair/tuple/tie versus C++17 structured bindings, inline anonymous structs with auto for locals, and the standard’s from_chars example that returns a struct (plus an out parameter). Tradeoff: structs are safer but more verbose unless language ergonomics improve.
AI-written summary · about
chapters (4)
- 0:00Start
- 0:13F.21: To return multiple "out" values, prefer returning a tuple or struct.
- 1:48Unwarranted tuples weaken the type system
- 3:01What about structs?
related talks
10mStructured Bindings demystified
01h 02mEmbracing Trailing Return Types and `auto` Return SAFELY in Modern C++
53mProduct Types for C++2x
26mThe Freedom of Static Typing
01h 00mThe Implementation of Value Types
23mFunctional Programming in C++ (Run time vs Compile time types)
48mBack to Basics: Cpp Value Semantics
36mThe language that isn't
