Quando provo a compilare questo codice (VS2010) ricevo il seguente errore:
error C3499: a lambda that has been specified to have a void return type cannot return a value
void DataFile::removeComments()
{
string::const_iterator start, end;
boost::regex expression("^\\s?#");
boost::match_results<std::string::const_iterator> 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(), [&expression, &start, &end, &what, &flags](const string& line)
{
start = line.begin();
end = line.end();
bool temp = boost::regex_search(start, end, what, expression, flags);
return temp;
});
}
Come ho specificato che lambda ha un tipo di ritorno "void". Inoltre, come faccio a specificare che lambda ha un tipo di ritorno "bool"?
AGGIORNARE
Il seguente compila. Qualcuno può dirmi perché si compila e l'altro no?
void DataFile::removeComments()
{
boost::regex expression("^(\\s+)?#");
boost::match_results<std::string::const_iterator> 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(), [&expression, &what, &flags](const string& line)
{ return boost::regex_search(line.begin(), line.end(), what, expression, flags); }));
}
->
, ad esempio[&](double d) -> double { //...