“A Semi Compile/Run-time Map with (Nearly) Zero Overhead Lookup”
summary
A semi compile-/run-time associative map stores where values live at compile-time using a templated global and constexpr lambda keys, then uses static local storage with placement new and std::launder to avoid UB; loading/storing values remains runtime and a runtime std::map of pointers provides a fallback. Lookups for compile-time keys compile down to a single machine instruction (global access speed). Compiles cost: ~20–30s for 1,000 keys, minutes for ~10,000; implementation uses unique_ptr with custom deleter for cleanup.
AI-written summary · about
chapters (15)
- 0:00Introduction
- 0:42Java wrapper performance issue
- 3:13Semi Map requirements
- 4:42Templated global storage
- 7:36Key to unique type mapping
- 9:01Wrapper class design
- 10:07Performance results
- 11:54Static local initialization
- 14:03Undefined behavior fix
- 15:48Runtime map integration
- 17:59Static vs instance storage
- 19:46Non-static map approach
- 21:30Benchmark comparison
- 22:33Compile-time trade-offs
- 23:16Q&A session
related talks
01h 04m“Constant Fun"
32mA Road Map for Lookup Tables
50mC++ Costless Abstractions: the compiler view
40mLife of a Clojure Expression
34mHash Maps: more room at the bottom
01h 18m“Variable Templates and Compile-Time Computation with C++14"
01h 01mExpressive Compile Time Parsers
01h 03mOLD VERSION: Understanding The constexpr 2-Step
