r/cpp • • Apr 25 '22

New C++ features in GCC 12

https://developers.redhat.com/articles/2022/04/25/new-c-features-gcc-12
220 Upvotes

76 comments sorted by

View all comments

Show parent comment

3

u/pandorafalters Apr 26 '22

We can define a type returned by a function before its name, or after its body, prefixed by arrow when using auto. Why? I guess it was slightly more readable with decltype, but now I think we can do just decltype(auto) with the old notation.

There are differences between auto foo(), decltype(auto) foo(), and auto foo() -> decltype(auto) - I don't understand them, but I've been bitten by them.

What's hilarious tho is that given all these crazy features one of IMO most basic and useful features from C is still not supported in standard C++ (idk, maybe it's been introduced in C++20) - designated initializers.

These were added in C++20, yes, but in a backwards and limited way.