Argument Passing, Core Guidelines and Aliasing
summary
Slides and benchmarks state that Core Guideline F-16 (pass cheaply copyable types by value, others by const reference) matters because aliasing can change correctness and slow hot loops dramatically: a measured case runs 43× slower when a coefficient is passed by const reference. Tools used include Compiler Explorer and Google Benchmark, and practical fixes shown are std::decay_copy and std::ref/std::bind tricks, plus a C++20 concepts + std::conditional pattern to choose value vs reference at compile time to avoid unnecessary copies and aliasing.
AI-written summary · about
chapters (12)
- 0:00Intro
- 1:42C++ Core Guideline F.16
- 3:48Examples
- 5:48What About Templates
- 6:37What's the Generic Approach (what's in STL)?
- 15:14Performance Effect of Aliasing
- 19:51Performance Benchmark Results
- 21:21Compilers and Aliasing
- 31:56Give Power to the Caller
- 39:52Herb Sutter's Code
- 45:33Potential Approach for Unification
- 48:49Summary
related talks
07mThe Perils of Strict Aliasing
01h 30m50 shades of C++
01h 03mHidden Overhead of a Function API
18mAliasing Limits on Translating C to Safe Rust
01h 00mThe Implementation of Value Types
01h 02mImplicit Conversions Considered Harmful
33mC++: Unexpected Behaviour
01h 00mDealing with aliasing using contracts
