title: C++ for_each algo and string
body: <p>I'm trying to loop through every letter of a string using for_each,</p>
  
  <pre><code>std::unordered_map&lt;std::string, unsigned int&gt; dico;
  std::for_each(str.begin(),str.end(),[&amp;](std::string l){
  if(dico.count(l) == 0){
       ' DO SOMETHING HERE
  })
  </code></pre>
  
  <p>However, I got one error message:</p>
  
  <pre><code>Error   2   error C2664: 'void `anonymous-namespace'::&lt;lambda2&gt;::operator ()(std::string) const' : cannot convert parameter 1 from 'const char' to 'std::string'
  </code></pre>
  
  <p>I tried to change to <code>char l</code>, however, it would break <code>dico.count(l)</code>. Instead, I have seen others using <code>for loop</code> instead. That solution worked. However, I wonder why <code>for_each</code> would not work here.</p>