title: C++ copy_if lambda capturing std::string
body: <p>This is a follow up question from here: <a href="https://stackoverflow.com/questions/20568278/c-developing-own-version-of-stdcount-if/20568936">C++ - Developing own version of std::count_if</a>?</p>
  
  <p>I have the following function:</p>
  
  <pre><code>// vector for storing the file names that contains sound 
  std::vector&lt;std::string&gt; FilesContainingSound; 
  
  void ContainsSound(const std::unique_ptr&lt;Signal&gt;&amp; s)
  {
      // Open the Wav file 
      Wav waveFile = Wav("Samples/" + s-&gt;filename_); 
  
      // Copy the signal that contains the sufficient energy 
  
      std::copy_if(waveFile.Signal().begin(), waveFile.Signal().end(), 
                   FilesContainingSound.begin(), [] (const Signal&amp; s) {
  
                       // If the energy bin &gt; threshold then store the 
                       // file name inside FilesContaining
                   }
  }
  </code></pre>
  
  <p>But to me, I only need to capture the string "filename" inside of the lambda expression, because I'll only be working with this. I just need access to the <code>waveFile.Signal()</code> in order to do the analysis.</p>
  
  <p>Anyone have any suggestions?</p>
  
  <p>EDIT:</p>
  
  <pre><code>std::vector&lt;std::string&gt; FilesContainingSound;
  std::copy_if(w.Signal().begin(), w.Signal().end(), 
               FilesContainingSound.begin(), [&amp;] (const std::unique_ptr&lt;Signal&gt;&amp; file) {
  
                   // If the energy bin &gt; threshold then store the 
                   // file name inside FilesContaining
               });
  </code></pre>