1

I have a template class taking 3 arguments, I need to bind 2 of them before and pass later that binded version to a "Parent" template template class I inherit from. (I've searched previously asked questions, but none tries to inherit from the parent.)

How could I make it work ?

Here is a sample code :

template <template<class> class W, class ...D>
struct Parent{};

template <class B, class T, class ...D>
struct Arg{};

template <class B, class ...D>
struct Bind{
    template <class T>
    using arg = Arg<B, T, D...>;
};

template <class B, class ...D>
struct DD : public Parent<Bind<B, D...>::t, D...> //compiler complains*
{ };

 * template argument for template template parameter must be a class template or type alias template.

I have tried using typename keyword ; and using a struct inheriting instead of a using directive in the Binder, none worked.

Julien__
  • 1,962
  • 1
  • 15
  • 25

1 Answers1

4

First of all, you probably meant Bind<B, D...>::arg instead of Bind<B, D...>::t in the code snippet.

Secondly, you need the template keyword, as Bind<B, D...> is a type-dependent id-expression. I.e.

template <class B, class ...D>
struct DD : public Parent<Bind<B, D...>::template arg, D...>
{ };
Columbo
  • 60,038
  • 8
  • 155
  • 203