For the following two lines of C++ code
map<string, vector<size_t> >::iterator beg = mapper.begin();
vector<size_t>& indics = (*beg).second;
How to understand what do they want to achieve, and in specific, what do the & and * in the second line of code mean?
We have a
mapthat maps fromstringtovector<size_t>. We get aniteratorto the first element in the map, that would be the one with the lesser key value, according tostd::less<string>.or what is the same
We get the second value in the key-value pair, that is we get the
vector<size_t>for the first element in the map. We keep a non-const reference to it, so we can modify its values.