Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

gcc 4.9 generic lambdas

There said https://gcc.gnu.org/projects/cxx1y.html, that generic lambdas supported since gcc 4.9.

But I tried following:

#include <iostream>

auto Identity = [](auto a) { return a; };

int main()
{
    std::cout << Identity(5) << std::endl;
}

And got error (-std=c++1y):

main.cpp:3:25: error: parameter declared 'auto'

 auto Identity = [](auto a) { return a; };

Is it still not supported by gcc 4.9? Or I miss some parameters?

like image 613
tower120 Avatar asked Mar 05 '26 15:03

tower120


1 Answers

It is because you're using the pre-release gcc 4.9 experimental, change to the released gcc 4.9 and it compiles fine. Demo

like image 150
101010 Avatar answered Mar 08 '26 06:03

101010



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!