C++ fixed-capacity associate container

  associative-array, c++, dictionary, stdmap

I am looking for a container like std::unordered_map that does not use any dynamic allocation. I believe this would be the case for any associate container with a fixed number of keys, or even keys that have to be chosen at compile time.

I am not looking for a constexpr or compile time hash map because I would like to be able to update the values in the map.

Example use case:

FixedCapacityMap<std::string_view, int> fruits {
  {"n_apples", 0},
  {"n_pairs", 0}
}

fruits["n_apples"] += 1;
fruits["n_pairs"] += 1;

Does anyone know if such a library exists, and if not how something like this could be implemented?

Source: Windows Questions C++

LEAVE A COMMENT