Using-declaration referring to base-class member using derived-class type is disallowed. Reconsider?

29 views
Skip to first unread message

Johannes Schaub

unread,
Jun 21, 2017, 5:13:22 AM6/21/17
to std-dis...@isocpp.org
There are valid usecases that are rendered ill-formed by a C++11
change made by DR#400. Consider

namespace bar {
template<typename T>
struct BarPotentiallyLongName { typedef T type; };
}

template<typename T>
struct Foo : bar::BarPotentiallyLongName<T> {
using typename Foo::type;
};

This is not allowed by C++11 rules, because

"In a using-declaration used as a member-declaration, each
using-declarator's nested-name-specifier shall name a base class of
the class being defined."

The user has to type out the potentially long base class name to refer
to the "type" member of the base class.

using typename Foo::BarPotentiallyLongName::type;

Or alternatively access the base class name through the
namespace-scope template-name , in which they need to pass the
template arguments additionally, which also introduces redundancy.
Reply all
Reply to author
Forward
0 new messages