“Function default arguments: Slingshot or Shotgun?”
summary
Function default arguments cause concrete pitfalls: names are bound at declaration, evaluated at call, multiple declarations merge defaults but the first declaration hides previous defaults inside a scope, and default-expression evaluation order is unspecified so two defaults calling next() can produce reversed results. Virtual overrides pick defaults by static type (breaking dynamic dispatch) and templates defer or reject bad default expressions at instantiation. Slides, code and a live demo (mocking and a source_location-style example) live on the conference GitHub and the demo compiles and runs as shown.
AI-written summary · about
chapters (12)
- 0:00Introduction and speaker background
- 8:42Slingshot or shotgun analogy
- 16:09Names bound at declaration evaluated at use
- 18:44Multiple declarations and visibility rules
- 28:42Member functions and default arguments
- 33:50Virtual functions and overrides
- 39:16Templates and default arguments
- 45:49Alternatives to default arguments
- 47:33Library TS and source location
- 50:36Constexpr context and runtime behavior
- 54:35Virtual dispatch and type identification
- 57:08Live demo and conclusion
related talks
07mAll the Default's Are Backwards
06mChange the Defaults in C++
54mNamed Arguments from Scratch
04mIf you're arguing, you're losing
01h 05mDon’t Get Overloaded by C++ Overload Sets
01h 03m“What Could Possibly Go Wrong?: A Tale of Expectations and Exceptions”
51mKeynote: There Is No Silver Bullet to Solve All C++ Software Problems
57mAnd Then() Some(T) Functional Adventures With C++23 std::optional and std::expected
