Personal Log - Where No Init Has Gone Before in C++
summary
Claim: C++17 can execute uncalled local code by instantiating a template on a consteval-compatible function pointer so a compile-time hash replaces literal log text and shipped binaries contain only numeric keys. A small DO_ON_INIT utility (implemented in under 20 lines) collects those source strings at global init into a decoder mapping, enabling readable logs later while keeping vanishing strings out of releases. Prototype works on MSVC, has GCC/clang portability caveats and is shown running end-to-end against a real codebase.
AI-written summary · about
chapters (25)
- 0:00Personal log exploration in C++
- 2:33Introduction
- 3:35Removing log strings from binaries
- 5:00Traditional logging challenges
- 6:03Advantages and drawbacks of hashing log strings
- 7:28Compile-time hashing for logs
- 9:16Log removal in production
- 10:20Decoding challenges and collaboration
- 12:33Static members forcing execution
- 15:43Linker errors with static data
- 16:50Static init with lambdas
- 18:55Function pointers in templates
- 20:20Macros and C++20 improvements
- 21:46Compiler compatibility issues
- 23:38Decoder tool design
- 27:32Debugging decoder call stacks
- 29:28Live demo: encoding/decoding
- 33:07Special technique enablers
- 34:53Compiler compatibility with static init
- 38:54Technique recap
- 39:57Performance and build impact
- 41:21Production limitations
- 44:07Additional static init uses
- 45:31Acknowledgments
- 45:54Q&A
related talks
01h 05mC++11 in the Wild: Techniques from a Real Codebase
59mCombining C++17 Features
01h 03mUnlocking the value of C++20
01h 39mKeynote - C++ Metaprogramming: evolution and future direction
56mPractical C++17
02h 02mPeering forward: C++'s next decade
01h 00mC++20 - the hidden pearls
52mExploring C++17 and beyond
