When I try and compile this code (VS2010) I am getting the following error:
error C3499: a lambda that has been specified to have a void return type cannot return a va
You can explicitly specify the return type of a lambda by using -> Type after the arguments list:
[]() -> Type { }
However, if a lambda has one statement and that statement is a return statement (and it returns an expression), the compiler can deduce the return type from the type of that one returned expression. You have multiple statements in your lambda, so it doesn't deduce the type.