learnbyexample@programming.dev to Linux@lemmy.mlEnglish · 1 day ago$HOME, Not So Sweet $HOMEgist.github.comexternal-linkmessage-square23fedilinkarrow-up182arrow-down16cross-posted to: gentoo@reddthat.comhackernews@lemmy.smeargle.fanstechnews@radiation.partyhackernews@derp.foo
arrow-up176arrow-down1external-link$HOME, Not So Sweet $HOMEgist.github.comlearnbyexample@programming.dev to Linux@lemmy.mlEnglish · 1 day agomessage-square23fedilinkcross-posted to: gentoo@reddthat.comhackernews@lemmy.smeargle.fanstechnews@radiation.partyhackernews@derp.foo
minus-squareschnurritolinkfedilinkarrow-up6·16 hours agoTIL that you can declare return types this way in C++.
minus-squareqaz@lemmy.worldlinkfedilinkEnglisharrow-up2·15 hours agoI never understood why they added that
minus-squareFeyd@programming.devlinkfedilinkarrow-up3·9 hours agoThey’re useful for templates because the trailing version is resolved later
minus-square_____@lemm.eelinkfedilinkEnglisharrow-up4·13 hours 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-squarebrisk@aussie.zonelinkfedilinkarrow-up6·15 hours agoAmong other things it lets you define the return type in terms of the arguments to the function.
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.