Reverse map lookup

c++, dictionary, stl

Solution

There isn't much you can do about it. Your have options to work with two maps, use multi-key map like one from Boost Multi-Index library, or do linear search.

UPDATE: The most lightweight out of the box solution seems to be Boost.Bimap, which stands for bi-directional map.

Problem

I have a 1 to 1 map. What's the best way to find keys from values, i.e. For examples if the map is this KEY VALUE ``` a 1 b 2 c 3 d 4 ``` I want to be able to find that key corresponding to 3 is C. Thanks!

Original source