In C ++ 11, two lines are equivalent. From what I see, the advantage of the second syntax is that the return type is in the class. Thus, you can use both nested class types and decltypenon-static member expressions . Moreover, function names line up well.
int foo(int bar);
auto foo(int bar) -> int;
It uses a keyword autothat can also be used to automatically obtain the type of local variables. However, I do not see an analogy here. The function declaration syntax fails. The return type is clearly indicated behind the arrow.
Personally, I would say that the syntax would be more understandable without a keyword auto. Are there any intentions behind this? What?
source
share