samedi 4 janvier 2020

What does the syntax [ ](const char &x, const char &y) { //do something;} mean when used inside calling a function? [duplicate]

This question already has an answer here:

See for example (taken from Haker Rank)


    string::iterator new_end = unique(input_string.begin(), input_string.end(), [] (const char &x, const char &y) {
        return x == y and x == ' ';
    });

I understand that the third arguement of the unique() method is a function --- is this just a way of defining a function inside calling a function? What is this type of formatting called, so I can read more about it. And what is the [] mean in this case?

Aucun commentaire:

Enregistrer un commentaire