C++ Trailing Return Types (2022)
10 points
13 days ago
| 2 comments
| danielsieger.com
| HN
konstantinua00
10 days ago
[-]
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

reply
haileys
10 days ago
[-]
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.

reply