Clean Integral Code
summary
Argues that raw integers cause surprising bugs and that code needs concrete choices: use bitset for flags, strongly typed ID or name-tagged wrappers instead of plain unsigned, prefer signed arithmetic for amounts and convert to signed quickly to avoid unsigned surprises, prefer iterators for indexing, and use libraries like Boost.MultiPrecision or safe numerix to catch overflow. Gives concrete refactor patterns, examples of UB from promotions, and a checklist of when an integer is the right tool.
AI-written summary · about
chapters (16)
- 0:00Introduction
- 7:20Questions
- 14:07Score
- 17:37Rules
- 20:09Single Purpose
- 22:20Integers
- 23:54Use Cases
- 26:20BitSet
- 27:59Boolean
- 29:21Exercise
- 34:13Text Manipulation
- 40:10Difference Types
- 41:47Objections
- 44:51Iterators
- 46:08Bugs
- 52:29Conclusions
related talks
05mSigned Integers: Faster and Corrector
01h 05mThe real problem of C++
01h 01mTo Int or to Uint, This is the Question
01h 30mC++ in Constrained Environments
01h 02mEmbedded Friendly C++: Features That Make a Difference
01h 29mPrincipia Mathematica - The Foundations of Arithmetic in C++
01h 01mBack to Basics: C++ API Design
51m0xBADC0DE
