Why would anyone bother writing it like that? That just seems like intmain() with extra steps. Like does auto enable some compiler optimisation of the return type that I’m not aware of?
Defining the return type that way can be used when dealing with template sorcery - there’s no use for it here though, not even for readability in any way.
What programming language is this even?!
Why would anyone bother writing it like that? That just seems like
int main()
with extra steps. Like does auto enable some compiler optimisation of the return type that I’m not aware of?Defining the return type that way can be used when dealing with template sorcery - there’s no use for it here though, not even for readability in any way.
Looks like C++.
TIL that you can declare return types this way in C++.
I never understood why they added that
They’re useful for templates because the trailing version is resolved later
because explicitly declaring types can be redundant, if the compiler knows a lot of the times you should also know
also because some types are extremely cursed: see std views/ranges
Among other things it lets you define the return type in terms of the arguments to the function.