<p>Multimap essentially has groups of data sorted by the key. I want a method by which I could access these individual groups and get their aggregate values.
For example, in a <code>std::multimap&lt; string, int &gt;</code> I store </p>

<pre><code>{"Group1", 1}, 
{"Group1", 2}, 
{"Group1", 3}, 

{"Group2", 10}, 
{"Group2", 11}, 
{"Group2", 12}
</code></pre>

<p>Having stored these values, I should be able to iterate this multimap and get the aggregate values of each "group". Problem is there aren't any functions defined in STL to access MultiMaps in such a way. I could use <code>lower_bound</code>, <code>upper_bound</code> to manually iterate the multimap and total the group's contents, but I am hoping there could be better ways already defined in STL ? Can anyone propose a solution as to how I could get the aggregate values for a group in the above example.</p>

If you already know the keys, you can use
```
multimap::equal_range
```
to get the iterators to the beginning and end of the group; use any standard algorithm to get the desired results from the range.  If you don't know the keys, you can start at
```
begin()
```
and iterate through them yourself, comparing keys to find the start of each new group.