title: C++ find multiple keys from a std::multimap
body: <p>I have an <code>STL::multimap</code> and which I search to populate a <code>std::list</code> with values where keys are duplicated. </p>
  
  <p>Can I find/insert to a <code>std::list</code>  the value of elements for all key where <code>count &gt; 1</code> without  counting them one by one?</p>
  
  <pre><code>std::multimap&lt;int, std::string&gt; mm ;
  mm[0] = "a" ;
  mm[1] = "b" ;
  mm[0] = "c" ;
  mm[2] = "j" ;
  mm[2] = "k" ;
  
  
  std::list&lt;std::string&gt; lst ;
  </code></pre>
  
  <p><code>lst</code> might contain <code>"a" ,"c","j","k"</code> ;</p>
  
  <p>I try this</p>
  
  <pre><code>template &lt;class K, class V&gt;
  class extract_value {
   private:
    K last_key_ ;
    std::list&lt;V&gt; m_list_value ;
    std::pair&lt;K, V&gt; first_elem ;
   public:
   extract_value(const K&amp; k_): last_key_(k_) { }
   void operator() (std::pair&lt;const K, V&gt; elem)
   {
    if (last_key_ == elem.first)
    {
     m_list_value.push_back(elem.second) ;
    }
    else
    {
     // First entry 
     last_key_ = elem.first;
     first_elem= elem ;
    }
   }
   std::list&lt;V&gt; get_value() { return m_list_value ; }
  };
  
  ex_ = for_each(mm.begin(),mm.end(), extract_value&lt;int, std::string&gt;(0)) ;
  std::list&lt;std::string&gt; lst = ex_.get_value() ;
  </code></pre>
  
  <p>I'm not sure if this code compiles.</p>