A hash map with 4-byte links, like std::unordered_map without the allocator parameter, node handles and the bucket interface.
Declared in <cptr/unordered_map.hpp>
template<
class K,
class V,
class Hash = std::hash<K>,
class KeyEqual = std::equal_to<K>,
class Cage = default_cage>
using unordered_map = detail::basic_unordered_map<K, V, Hash, KeyEqual, Cage, true>;
Separate chaining; nodes and buckets are allocated in Cage: about 20 bytes per element for 4-byte keys and values, against 44 for std::unordered_map. The members behave like those of std::unordered_map, with these differences: there is no allocator parameter, no node handles (extract, merge, insert of a node), no bucket interface (bucket(), bucket_size(), local iterators) and no get_allocator(); bucket counts are powers of two, at most max_bucket_count(); hints are accepted but not used; and the iteration order is that of the buckets. See detail::basic_unordered_map for the full member list. Lookup is heterogeneous when both Hash and KeyEqual are transparent; so is erase, C++23 style, when CPTR_HETEROGENEOUS_ERASE is defined.
#include "cptr/unordered_map.hpp"
cptr::unordered_map<std::uint32_t, float> prices;
prices.reserve(1000);
prices[42] = 9.5f;
if (auto it = prices.find(42); it != prices.end()) { /* ... */ }