Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7516231
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T01:04:01+00:00 2026-05-30T01:04:01+00:00

Can a template template variadic be used to catch all cases of a template

  • 0

Can a template template variadic be used to catch all cases of a template parameter being passed that is itself a template?

I’ve been using templating to produce debug output for some template based methods. Firstly, I created a generic handler, then specialised it for native types:

template<typename... PARAMS> struct TypeList{};

template<typename TYPE> inline void ntype(ostream &out, TypeList<TYPE>) {
    out << typeid(TYPE).name();
}

template<> inline void ntype(ostream &out, TypeList<int>) {
    out << "int";
}

...

Then I tried to add a second template format to catch template types being passed:

template<typename ... SUB, template<typename...> class TYPE> void ntype(ostream &out, TypeList<TYPE<SUB...> >) {
    ntype(out, TypeList<typename TYPE>());
    out << '<';
    subtype(out, TypeList<SUB...>());
    out << '>';
}

Where subtype is a template method designed to recurse through the param list, applying each to ntype() in turn.

The problem is when I attempt to call this with something to the effect of:

ntype<SomeClass<int> >(out, TypeList<SomeClass<int> >());

It only ever matches the generic first template function – no compilation errors, but it never matches the template template version. I’m sure its merely a lack of understanding on my part, but google results seem very thin on the ground when it comes to clear examples of template templates, and even thinner with regards to variadic template params.

Can anyone explain whether what I’m attempting is even possible and, if so, what I’m doing wrong?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T01:04:02+00:00Added an answer on May 30, 2026 at 1:04 am

    It appears I merely had a typo – I had added () after one of my TypeLists in a function declaration, probably from copy and pasting from a function invocation at 3am, which was causing the mismatch.

    So, in case anyone is wondering, yes it is possible, and the above is a perfectly acceptable way to do it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

C++0x thread library or Boost.thread define a non-member variadic template function that locks all
As i Understand export keyword can be used so that one can expose template
I can use VS08's MFC/ActiveX template to create a C++ ActiveX object that I
Can anybody recommend a decent C# Mapper Pattern code generation template that plays nicely
How can I pass a variable value from a template using JavaScript without using
I don't know if this can be achieved through variadic template, variadic marcos or
Possible Duplicate: trailing return type using decltype with a variadic template function I want
I have a variadic template function which calls itself to determine the largest number
Can someone tell me how I can template a treeview control so that it
A hypothetical variadic template tuple class would, as far as I can tell, have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.