Avoid qualifying a nested type name

suggest change
class ClassWithAReallyLongName {
  public:
    class Iterator { /* ... */ };
    Iterator end();
};

Defining the member end with a trailing return type:

auto ClassWithAReallyLongName::end() -> Iterator { return Iterator(); }

Defining the member end without a trailing return type:

ClassWithAReallyLongName::Iterator ClassWithAReallyLongName::end() { return Iterator(); }

The trailing return type is looked up in the scope of the class, while a leading return type is looked up in the enclosing namespace scope and can therefore require “redundant” qualification.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:


Trailing return type:
* Avoid qualifying a nested type name

Table Of Contents
8 Arrays
11 Loops
39 Streams
51 Unions
56 Lambdas
60 SFINAE
62 RAII
67 Sorting
84 RTTI
87 Scopes
92 Trailing return type
104 Profiling
107 Recursion
117 Iteration
125 Alignment
134 Semaphore
136 Debugging
139 Mutexes
142 decltype