dimanche 19 juillet 2020

c++ lambda can't convert to int

I attempting to use a nested lambda as follows:

int main() {
    auto x=[](int a){
        return [a](int b){
            return a+b;
        };
    };

    int xx = x(1)(2);
    
    (void)xx;
    return 0;
}

However, the vs2013 compiler yields an error (C++11 language level):

[...] can't convert to int.

What is wrong?

Aucun commentaire:

Enregistrer un commentaire