Summary
This episode compares the performance of std::map with a simple hand-crafted constexpr map implementation. Jason demonstrates how using a constexpr-friendly map implementation results in dramatic runtime performance improvements, showing up to 100x faster lookups in benchmarks. He explains that the constexpr map, despite using a simple linear search algorithm rather than a binary search, enables better compiler optimizations for small to medium size datasets, resulting in fewer heap allocations and potential inlining of lookup code.
Related C++ Standard Sections
This episode covers topics found in these sections of the C++ standard:
-
[alg.find]40% match -
[pairs]40% match -
[range.error]40% match