Understanding And Mastering Flat Containers
summary
C++23 adds std::flat_ containers implemented as sorted contiguous sequences; the presenter builds naive versions and compares them to std::map and Boost flat_map using homemade benchmarks (release build on a personal PC, elements 10→100k, types: 16/32/64-bit and 3×64-bit). Results show logarithmic find and iteration often beat tree maps (notably at 100k elements), while insert/erase are linear and can invalidate iterators. Recommendation: use for 10–1000 elements* or read-heavy, prebuilt caches; works but needs per-project benchmarking.
AI-written summary · about
chapters (22)
- 0:00Flat containers intro
- 1:09C++ containers overview
- 2:55Associative containers core
- 4:24std::set and tree internals
- 7:58Flat vs tree containers
- 10:36Find in flat containers
- 12:46Insert/erase in flat containers
- 15:38flat_map implementations
- 18:06Iterators for flat containers
- 21:00flat_map insert/erase
- 23:34Flat containers performance
- 24:17Cache locality and fragmentation
- 29:21Benchmarks vs standard maps
- 33:22Find benchmarks
- 35:08Insert benchmarks
- 36:56Erase benchmarks
- 38:23Iteration performance
- 39:28Standard vs flat containers
- 41:56Flat containers in production
- 43:24Best practices for flat containers
- 44:50Memory overhead benefits
- 46:16Q&A
related talks
37mEnhancing STL containers
01h 13m"Mostly Invalid": flat_map, Exception Guarantees, and the STL
56m“High Performance Code 201: Hybrid Data Structures"
32mC++ Standard Library "Little Things”
59mStrongly Typed Containers
01h 02m“How to Choose the Right Standard Library Container, and Why You Should Want Some More”
01h 13mPractical Production-Proven Constexpr API Elements
36mInterfaces Matter
