title: "Capture" variables in lambda function parsed as argument
body: <p><em>I have no idea what to title this question as, sorry.</em></p>
  
  <hr>
  
  <p>I have a function in C++ which takes a lambda as a parameter.</p>
  
  <pre><code>void LoopPixels(cv::Mat &amp;img, void(*fptr)(uchar &amp;r, uchar &amp;g, uchar &amp;b)) {
      // ...
      fptr(r, g, b); // Call the lambda function
  }
  </code></pre>
  
  <p>Then I am trying to call this <code>LoopPixels</code> function.</p>
  
  <pre><code>int threshold = 50;
  LoopPixels(img, [](uchar &amp;r, uchar &amp;g, uchar &amp;b) {
      r *= (uchar)threshold; // Unable to access threshold :(
  });
  </code></pre>
  
  <p>My problem is, I cannot access the <code>threshold</code> variable from inside the lambda function, and if I try to <em>"catch"</em> it with <code>[&amp;threshold](uchar &amp;r...){}</code>, I receive an error telling me the lambda I parsed into <code>LoopPixels</code> is of the wrong type.</p>
  
  <p>Error message:</p>
  
  <blockquote>
    <p>no suitable conversion function from "lambda []void (uchar &amp;r, uchar
    &amp;g, uchar &amp;b)->void" to "void (*)(uchar &amp;r, uchar &amp;g, uchar &amp;b)"
    exists</p>
  </blockquote>
  
  <p><strong>How can I access variables within a lambda which has been parsed as a function argument?</strong></p>