Relative Content

Tag Archive for c++dictionaryc++14

How to insert a key if not present to a transparently compared map?

I have a std::map<K, T, std::less<>> and a “key” of type KK which is order-compatible with K. If the key is present, I want to return the corresponding value. If the key is not present, I want to materialize a real key (of type K) and insert a key–value pair with default constructed T into the map.