learnbyexample to Linux@lemmy.mlEnglish · 1 month ago$HOME, Not So Sweet $HOMEgist.github.comexternal-linkmessage-square22fedilinkarrow-up192arrow-down14cross-posted to: [email protected]
arrow-up188arrow-down1external-link$HOME, Not So Sweet $HOMEgist.github.comlearnbyexample to Linux@lemmy.mlEnglish · 1 month agomessage-square22fedilinkcross-posted to: [email protected]
minus-squareschnurrito@discuss.tchncs.delinkfedilinkarrow-up6·1 month agoTIL that you can declare return types this way in C++.
minus-squareqaz@lemmy.worldlinkfedilinkEnglisharrow-up2·1 month agoI never understood why they added that
minus-squarebrisk@aussie.zonelinkfedilinkarrow-up6·1 month agoAmong other things it lets you define the return type in terms of the arguments to the function.
minus-square_____@lemm.eelinkfedilinkEnglisharrow-up5·1 month agobecause 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
minus-squareFeydlinkfedilinkarrow-up3·1 month agoThey’re useful for templates because the trailing version is resolved later
TIL that you can declare return types this way in C++.
I never understood why they added that
Among other things it lets you define the return type in terms of the arguments to the function.
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
They’re useful for templates because the trailing version is resolved later