logoalt Hacker News

jjmarryesterday at 6:30 AM4 repliesview on HN

I don't understand why anyone would use auto and a trailing return type for their functions. The syntax is annoying and breaks too much precedent.


Replies

dataflowyesterday at 6:43 AM

Generally, you don't. I'm not sure why the parent suggested you should normally do this. However, there are occasional specific situations in which it's helpful, and that's when you use it.

gpderettayesterday at 1:16 PM

1) consistency, 2) scoping is different and can make it a significant difference.

I have been programming in C++ for 25 years, so I'm so used to the original syntax that I don't default to auto ... ->, but I will definitely use it when it helps simplify some complex signatures.

Rucadiyesterday at 8:14 AM

it makes function declarations/instantiations much more grep-able.

rovingeyeyesterday at 7:01 AM

Consistency (lambdas, etc.)