The return type of a lambda (in C++11) can be deduced, but only when there is exactly one statement, and that statement is a return
statement that returns an expression (an initializer list is not an expression, for example). If you have a multi-statement lambda, then the return type is assumed to be void.
Therefore, you should do this:
remove_if(rawLines.begin(), rawLines.end(), [&expression, &start, &end, &what, &flags](const string& line) -> bool
{
start = line.begin();
end = line.end();
bool temp = boost::regex_search(start, end, what, expression, flags);
return temp;
})
But really, your second expression is a lot more readable.