Comment by Ballas

8 days ago

Why would anybody think more words more better?

    int main() {

The trailing return type pattern was added to the standard, IIRC, to make it easier for templated functions to have return types that depend on the types of the arguments, such as in this example:

    template <typename A, typename B>
    auto multiply(A a, B b) -> decltype(a * b) {
        return a * b;
    }

Its easier for the compiler to parse everything if `decltype(a * b) occurs _after_ the definition of `a` and `b`. Once this pattern was added and people started using it for that purpose, people also started using the pattern for all functions for consistency.

  • Yes, in that case I completely agree. Using it everywhere is a mistake IMHO. I know there might be a stylistic reason for using it everywhere, but I believe less code is better, unless more code makes it easier to understand.