1

It seems to me, that since in C++ we can pass a template template, then a function accepting a template template should be able to pass a (its) template template into itself. However this appears not to be the case.

template< typename PREVIOUS_TYPE_T, typename TYPE_T >
struct Node
{
    typedef TYPE_T TYPE;
    typedef PREVIOUS_TYPE_T PREVIOUS_TYPE;
    PREVIOUS_TYPE_T* previous;
    template< template< typename... > typename FUNCTOR_T, typename... CURRENT_ARGUMENTS_T >
    void DoCall() {
        previous->DoCall< FUNCTOR_T, TYPE_T, CURRENT_ARGUMENTS_T... >();
    }
};

Is there anyway to pass FUNCTOR_T above, or any work around to doing so?

  • 1
    I'm not sure, what was wrong with your original revision? The revisions could affect the answer. Could you clarify which one you actually mean and why? –  Aug 15 '19 at 21:37
  • @Chipster Thank you for your response. The original version was copy/pasted from an old file, not with the one I am currently working with which is what you see above. The old version had `template< typename... ARGUMENTS_T > typename FUNCTOR_T` and passes `ARGUMENTS_T` into the last (variadic) parameter of `DoCall` in the recursive call, which causes an obvious problem and isent what I am asking. What I am asking is: is there a way or work around to pass a template template parameter to a function called inside another function (or functor, etc.) to the effect of what is above? – The Floating Brain Aug 15 '19 at 21:45

1 Answers1

1

You cannot use ARGUMENTS_T. That name has no effect.

When you're passing a template template around, it's still a template with no parameters passed to it. There is no template parameter to extract from std::plus, as opposed to std::plus<int>.

Instead, use CURRENT_ARGUMENTS_T, which is what you intended to forward.

Also, you previous is a dependent type. You must desambiguate the template:

previous->template DoCall< FUNCTOR_T, TYPE_T, CURRENT_ARGUMENTS_T... >();
Guillaume Racicot
  • 39,621
  • 9
  • 77
  • 141