“The Importance of Being const"
summary
Explains that const enforces invariants at compile time but in C++11 also carries a const implies data-race-free guarantee so mutable caching or logging inside const member functions can create subtle races. Shows a concrete checksum cache bug where copy construction and member initialization order produce wrong cached values, demonstrates fixing counters with use std::atomic for counters or mutexes (noting they make objects noncopyable), recommends writing types as T const name and says const helps correctness not automatic optimization.
AI-written summary · about
chapters (15)
- 0:00Introduction
- 1:05What is const
- 2:50Pointer const rules
- 10:28Const with structs
- 15:12Const in function calls
- 17:43Const member functions
- 20:16Const and invariants
- 24:35Const member function rules
- 25:59Logical vs bitwise const
- 27:27Mutable for caching
- 29:12Thread safety with const
- 35:14Caching in const functions
- 45:29Does const optimize code
- 48:22Summary and best practices
- 49:22Q&A








