The Surprising Costs of void() (and Other Not-Quite-Innocuous Evils)
summary
Shows that plain void() functions with no inputs or outputs often hide mutations and global-state plumbing, leading to unclear interfaces and wasted work; unnecessary default-initialization can add runtime costs; removing an unneeded virtual can save 8-byte per-object vtable cost (40→32 bytes in an example); capturing locals by reference in lambdas and C-style casts across calling conventions produce silent UB that sometimes “works” under some compilers; examples come from anonymized intern code and real product docs, and compilers/optimizers plus Visual Studio static analysis partly detect but don’t eliminate these pitfalls.
AI-written summary · about
chapters (14)
- 0:00Introduction and context
- 2:11Analyzing code smells
- 5:00Void functions and signatures
- 7:27Contextual meaning in code
- 10:41Virtual functions and design
- 13:04Optimizing class hierarchies
- 16:33Unnecessary initialization
- 20:51Efficient variable usage
- 27:35Control flow and initialization
- 30:16Interfaces and defaults
- 34:29Error handling and design
- 37:12Const correctness
- 40:54Avoiding shortcuts and hacks
- 50:15Lambda pitfalls and conclusion
related talks
01h 01mSome Programming Myths Revisited
32mCute C++ Tricks, Part 2 of N: More code you should learn from and never write
01h 00mThere Are No Zero-cost Abstractions
59mC++ Code Smells
55mBreaking Dependencies: Type Erasure - The Implementation Details
02h 25mHow to Keep C++ Binaries Small - Techniques for C++ Optimization
46mC++: No more nulls! (Fixing the billion dollar mistake)
57m“The Nightmare of Move Semantics for Trivial Classes”
