Something like that?
template<class Key, class Value, template<class...>class Storage=std::vector> struct flat_map { struct kv { Key k; Value v; template<class K, class V> kv( K&& kin, V&& vin ):k(std::forward<K>(kin)), v(std::forward<V>(vin)){} }; using storage_t = Storage<kv>; storage_t storage;
I left the container type as the template argument, so you can use the SBO vector structure if you choose.
In theory, I should set a template parameter to replace equals on keys. However, I made transparent key search functions.
source share