title: Explicit Return Type of Lambda
body: <p>When I try and compile this code (VS2010) I am getting the following error:
  <code>error C3499: a lambda that has been specified to have a void return type cannot return a value</code></p>
  
  <pre><code>void DataFile::removeComments()
  {
    string::const_iterator start, end;
    boost::regex expression("^\\s?#");
    boost::match_results&lt;std::string::const_iterator&gt; what;
    boost::match_flag_type flags = boost::match_default;
    // Look for lines that either start with a hash (#)
    // or have nothing but white-space preceeding the hash symbol
    remove_if(rawLines.begin(), rawLines.end(), [&amp;expression, &amp;start, &amp;end, &amp;what, &amp;flags](const string&amp; line)
    {
      start = line.begin();
      end = line.end();
      bool temp = boost::regex_search(start, end, what, expression, flags);
      return temp;
    });
  }
  </code></pre>
  
  <p>How did I specify that the lambda has a 'void' return type. More-over, how do I specify that the lambda has 'bool' return type?</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>The following compiles. Can someone please tell me why that compiles and the other does not?</p>
  
  <pre><code>void DataFile::removeComments()
  {
    boost::regex expression("^(\\s+)?#");
    boost::match_results&lt;std::string::const_iterator&gt; what;
    boost::match_flag_type flags = boost::match_default;
    // Look for lines that either start with a hash (#)
    // or have nothing but white-space preceeding the hash symbol
    rawLines.erase(remove_if(rawLines.begin(), rawLines.end(), [&amp;expression, &amp;what, &amp;flags](const string&amp; line)
    { return boost::regex_search(line.begin(), line.end(), what, expression, flags); }));
  }
  </code></pre>