Suppose some data structure:
typedef struct { std::string s; int i; } data;
If I use the field data.s as key when adding i
data.s
C++11
Since C++11 reference wrapper is part of standard.
#include std::map, data>
Using Boost
You may want to take a look at boost.ref. It provides a wrapper that enables references to be used in STL-containers like this:
std::map, data>