Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
C++ Trailing Return Types (2022) (danielsieger.com)
10 points by susam 6 months ago | hide | past | favorite | 2 comments


I prefer to never use it

C and C++ are about types before names - and modifying that is simply a change for the sake of a change, needless and useless. There's a lot of education enertia behind it - and effort should be spent on fighting what matters (like smart pointers), not hip/non-hip declaration style

decltype(a*b) is the only good "escape hatch"-type excuse for it, but idk why everyone make such a big deal out of it - when was the last time return type was both unpredictable AND needed to be specified? by that point you're already too deep


Well, `override` going after the return type is certainly confusing.

I was recently tripped up by putting `const` at the end, where `override` is supposed to go. It compiled and worked even. It wasn't until later on when something else suddenly failed to compile that I realised that `const` in that position was a modifier on the return type, not the method.

So `const` goes before the -> but `override` goes after the return type. Got it.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: