Skip to content(if available)orjump to list(if available)

C++ Trailing Return Types (2022)

C++ Trailing Return Types (2022)

2 comments

·July 17, 2025

konstantinua00

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

haileys

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.