Avoid qualifying a nested type name

suggest change
class ClassWithAReallyLongName {
    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:

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

Table Of Contents