I'm trying to use a using
directive to bring in the public
access declaration of a derived class some inner class template declared in the base. Code:
template <typename T>
class Base
{
public:
template<typename U>
struct Inner;
};
template<typename T>
class Derived: private Base<T>
{
public:
using typename Base<T>::template Inner; // make it visible
Inner<T>* ptr; // no need for typename here, non-qualified name
};
int main() {}
Neither g++ nor clang++ compile this code, both complaining about
error: expected unqualified-id before 'template'
As far as I know, Inner
is a dependent template name, so one should use ::template
when qualifying its name, and also a typename
before, since Base<T>::Inner
is a dependent type. I've tried all possible combinations with/without typename/template
, and none compile. Is there any way of using Inner
in the public
section of Derived
?
Aucun commentaire:
Enregistrer un commentaire