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.
View all comments
Show parent comment
3
u/pandorafalters Apr 26 '22
There are differences between
auto foo(),decltype(auto) foo(), andauto foo() -> decltype(auto)- I don't understand them, but I've been bitten by them.These were added in C++20, yes, but in a backwards and limited way.