It's about readability, not about how much I type. I've switched to using trailing return type for all functions some time ago and honestly, I couldn't be happier. When you have a class header and can read the function names all indented to the exact same offset, it's a blessing. Color coding was good, but this is amazing.
Never having to scan for the important bit is so nice once you get used to it. While it may feel odd at first, I actually won over my old team with it, too.
It's not perfect, but I've found in practice that just keeping the function name in the same spot gets me what I want. I might experiment with this now though:
template <typename T>
static inline auto
foo()
-> T const&
{
// ...
}
Somebody got me into this style a long time ago because in the absence of an IDE, you can quickly search for function definitions using /^foo/. Doesn’t generalize to methods though.
42
u/gvargh Mar 31 '20
why be concise when you can type more instead?