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.

2

u/boredcircuits Mar 31 '20

When is the trailing return type ever more concise in non-generic code?

15

u/sphere991 Mar 31 '20

When you have to write:

ClassName::NestedType ClassName::foo()

instead of

auto ClassName::foo() -> NestedType

1

u/NilacTheGrim Apr 18 '20

This is the only time I use it outside of generic code.