# How fast is C++23's std::flat\_map?

DevFeed: [How fast is C++23's std::flat\_map?](<https://devfeed.tech/articles/how-fast-is-c-23-s-std-flat-map-31465.md>)

Original publisher: [Read original article](<https://lemire.me/blog/2026/09/16/how-fast-is-c23s-stdflat_map/>)

Author: Daniel Lemire

Published: 2026-09-16T20:26:36Z

Content type: article

Language: en

Sources: [Daniel Lemire](<https://devfeed.tech/sources/daniel-lemire.md>)

Topics: [Data structures](<https://devfeed.tech/topics/data-structures.md>), [Library](<https://devfeed.tech/topics/library.md>), [gcc](<https://devfeed.tech/topics/gcc.md>), [LLVM](<https://devfeed.tech/topics/llvm.md>), [clang](<https://devfeed.tech/topics/clang.md>)

Tags: [array](<https://devfeed.tech/tags/array.md>), [arrays](<https://devfeed.tech/tags/arrays.md>), [clang](<https://devfeed.tech/tags/clang.md>), [gcc](<https://devfeed.tech/tags/gcc.md>), [llvm](<https://devfeed.tech/tags/llvm.md>), [overhead](<https://devfeed.tech/tags/overhead.md>), [speed](<https://devfeed.tech/tags/speed.md>), [standard-library](<https://devfeed.tech/tags/standard-library.md>)

## AI overview

This article benchmarks C++23's std::flat_map, a sorted container backed by parallel arrays of keys and values. It explains serialization and loading considerations, then compares insertion and lookup performance with std::map. Random-order insertion becomes quadratic as the container grows, while increasing-order or bulk insertion is much faster; random lookups can also be faster for large maps because std::flat_map uses less memory.

## Source excerpt

C++23 added a new type to the standard library: std::flat_map. There is also a std::flat_set and other variants, but let me focus on std::flat_map. A flat map is a sorted vector of keys next to a vector of values. A query is a binary search over the sorted keys. You need a recent standard library: ... Continue reading How fast is C++23's std::flat_map?