title: C++ std::map<std::string, int> get values whose key starts with a particular string
body: <p>I'm using std::map in such a way:</p>
  
  <pre><code>#include &lt;map&gt;
  #include &lt;string&gt;
  #include &lt;iostream&gt;
  
  using namespace std;
  
  int main(int argc, char* argv[])
  {
      map&lt;string, int&gt; my_map;
  
      my_map.insert(pair&lt;string, int&gt;("Ab", 1));
      my_map.insert(pair&lt;string, int&gt;("Abb", 2));
      my_map.insert(pair&lt;string, int&gt;("Abc", 3));
      my_map.insert(pair&lt;string, int&gt;("Abd", 4));
      my_map.insert(pair&lt;string, int&gt;("Ac", 5));
      my_map.insert(pair&lt;string, int&gt;("Ad", 5));
  
      cout&lt;&lt;my_map.lower_bound("Ab")-&gt;second&lt;&lt;endl;
      cout&lt;&lt;my_map.upper_bound("Ab")-&gt;second&lt;&lt;endl;
      return 0;
  }
  </code></pre>
  
  <p><a href="http://ideone.com/5YPQmj" rel="noreferrer">http://ideone.com/5YPQmj</a></p>
  
  <p>I'd like to get all values whose key starts with a particular string (for example "Ab"). I can easily get the begin iterator using map::lower_bound. But how can I get an upper bound? Do I have to iterate the whole set starting at lower bound and check every key if it still starts with "Ab"?</p>