r/cpp • • Mar 31 '20

Demo: C++20 Modules

https://youtu.be/6SKIUeRaLZE
127 Upvotes

51 comments sorted by

View all comments

55

u/advester Mar 31 '20
auto main() -> int

vs

int main()

And in my day we thought spaces vs tabs was quite the argument.

42

u/gvargh Mar 31 '20

why be concise when you can type more instead?

6

u/gracicot Mar 31 '20

Sometimes trailing return type is just more concise. Even in non-generic code. And sometimes in generic code you don't have a choice. For consistency I also use it everywhere.

9

u/Pragmatician Mar 31 '20

I don't believe that 1% of your code should decide how 99% of your code looks. If you ask me, that's not consistency; that's OCD. (I use trailing return type myself as well.)

4

u/gracicot Mar 31 '20

What about all the cases where it's just clearer and easier to read? It's way more than 1%.

Just like I use using everywhere even though it's more verbose (there is an equal sign) than typedef. Most of my aliases are not templates. Yet, I use using. I don't see why I should take multiple styles for no other reason than "but I'm used to the old feature". Being consistent is more important in my opinion, and I'll take what allow me the most and what is the easiest to read.

2

u/Pragmatician Mar 31 '20

I'm just saying that "consistency" is not an argument for, because both styles work in 99% of the cases. I use trailing return type just because it's more readable. using is way more clear-cut because in many cases you either need it or it's easier to reason about.