jeudi 11 février 2021

Access templated "using" in templated parent class

I have a class hierarchy like this:

/* Base templated interface class */
template <class T>
class InterfaceClass {
  public:
    // Normal using sentence
    using InnerType1 = SomeClass<T>;

    // HERE1: Templated using sentence that I want to use in other places
    template<typename SomeType>
    using TplInnerType = SomeOtherClass<InnerType1, SomeType>; 
};

/* Some templated intermediate class inheriting from the interface */
template <typename T>
class Class : InterfaceClass<T> {
  using BaseType = InterfaceClass<T>;

  // This works
  using typename BaseType::InnerType1;

  // HERE2: This won't work in any form
  using typename BaseType::TplInnerType;
};

/* Then I have some children using the CRTP as: */
class Child1 : Class<Child1> { ... };
class Child2 : Class<Child2> { ... };

I would like to use the templated using sentence (HERE1) from InterfaceClass in descendants (HERE2), but I cannot get the compiler (C++11 over clang 10) to resolve the type. I have tried many combinations following compiler advice, including:

  template <typename T> using typename BaseType::TplInnerType<T>;
  template <typename T> using TplInnerType = BaseType::TplInnerType<T>;
  template <typename T> using TplInnerType = typename BaseType::TplInnerType<T>;
  template <typename T> using TplInnerType = BaseType::template TplInnerType<T>;

But suggestions drive my in a circle... Is what I try to do even possible?

Aucun commentaire:

Enregistrer un commentaire