static_maps: consteval std::map and std::unordered_map Implementations in C++23

Fuente: arXiv
Saved in:
Bibliographic Details
Main Authors: Myhal, Isaac D., Serang, Oliver
Format: Preprint
Published: 2026
Subjects:
Online Access:
Tags: Add Tag
No Tags, Be the first to tag this record!
_version_ 1866914352230039552
author Myhal, Isaac D.
Serang, Oliver
author_facet Myhal, Isaac D.
Serang, Oliver
contents Using consteval from C++23, we implement efficient, new versions of std::map and std::unordered_map for use when the keys are known at compile time. We demonstrate superior performance of our unordered_map on three demonstration use-cases: Lookup of elemental mass from atomic symbol, lookup of amino acid from codon, and modification of stock prices from S&P 500 ticker symbols all produced runtimes <40%, <35%, <73% of the respective runtimes of the std implementations. Our library runimes were <80%, <45%, <97% of the lookup time of Frozen, an alternative perfect hashing implementation in C++ for problems also using constexpr keys. To our knowledge, this makes our library the overall fastest drop-in (i.e., with a similar API) alternative to std::unordered_map. On one arbitrarily chosen demo, we demonstrate runtimes <35% of PTHash and <89% gperf, state-of-the-art but not drop-in hashing libraries via external tools.
format Preprint
id arxiv_https___arxiv_org_abs_2602_22506
institution arXiv
publishDate 2026
record_format arxiv
spellingShingle static_maps: consteval std::map and std::unordered_map Implementations in C++23
Myhal, Isaac D.
Serang, Oliver
Data Structures and Algorithms
Software Engineering
E.1; F.2.2; D.2.13
Using consteval from C++23, we implement efficient, new versions of std::map and std::unordered_map for use when the keys are known at compile time. We demonstrate superior performance of our unordered_map on three demonstration use-cases: Lookup of elemental mass from atomic symbol, lookup of amino acid from codon, and modification of stock prices from S&P 500 ticker symbols all produced runtimes <40%, <35%, <73% of the respective runtimes of the std implementations. Our library runimes were <80%, <45%, <97% of the lookup time of Frozen, an alternative perfect hashing implementation in C++ for problems also using constexpr keys. To our knowledge, this makes our library the overall fastest drop-in (i.e., with a similar API) alternative to std::unordered_map. On one arbitrarily chosen demo, we demonstrate runtimes <35% of PTHash and <89% gperf, state-of-the-art but not drop-in hashing libraries via external tools.
title static_maps: consteval std::map and std::unordered_map Implementations in C++23
topic Data Structures and Algorithms
Software Engineering
E.1; F.2.2; D.2.13
url https://arxiv.org/abs/2602.22506