mardi 23 juin 2020

c++ lambda function with default capture type

I am new in c++11 and 14, and I am wondering why in this case

auto c1 = (bool (*)(int))[](int y) {
    return y%2 == 0;
};

the conversion is successful, but when the lambda function has the default capture type, then the conversion fails?

auto c1 = (bool (*)(int))[=](int y) {
    return y%2 == 0;
};

Aucun commentaire:

Enregistrer un commentaire