mardi 28 août 2018

Lambda function declaration in function declaration


I saw article referring to similar code with a lambda function declaration as a parameter of the function:

static bool MyClass::myFunction(std::string data, std::string message, [&server](bool activate))
{
    if (MyClass::info == "local") {
        server.connect("localhost, ...");
    } else {
        server.connect(data);
    }
   server.send(message);
   server.disconnect();
}

I am little bit confused about parameter #3 of the function "myFunction". My questions are:

✓ Is is lambda definition or declaration?
✓ Where is a body of the lambda function?
✓ How can I call the function "MyClass::myFunction" from my code?
✓ Is it regular C++11 or C++14 standard?
✓ I have tried to find some articles about this lambda declaration, but I was not successful. Could you provide me some links with articles about that?

Tank's a lot!

Aucun commentaire:

Enregistrer un commentaire