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 7050667
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T03:10:16+00:00 2026-05-28T03:10:16+00:00

Is a way to compose a template<int> from the template<int, int> I have tried

  • 0

Is a way to compose a template<int> from the template<int, int>

I have tried the following code, but it does not compile:

#include <iostream>
template<int N, int M>
struct A { enum E { n = N, m = M }; };

template<template<int> class C>
struct B : public C<8> { };

int main(int argc, const char *argv[])
{
    typedef B< A<4> > T;
    T b;

    std::cout << T::n << std::endl;
    std::cout << T::m << std::endl;
    return 0;
}

Error:

test3.cxx: In function ‘int main(int, const char**)’:
test3.cxx:10:23: error: wrong number of template arguments (1, should be 2)
test3.cxx:3:12: error: provided for ‘template<int N, int M> struct A’
test3.cxx:10:25: error: template argument 1 is invalid
test3.cxx:10:28: error: invalid type in declaration before ‘;’ token
test3.cxx:13:22: error: ‘T’ is not a class or namespace
test3.cxx:14:22: error: ‘T’ is not a class or namespace
  • 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-28T03:10:17+00:00Added an answer on May 28, 2026 at 3:10 am

    At least in C++03 a template template parameter must have exactly the number of arguments required.

    One way to achieve this would be to create a new template with the right arity that delegates to the original template:

    template<int M>
    struct Hack : A<4, M> { };
    
    ...
    
    typedef B<Hack> T;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Two way binding does not work on my custom control with the following internals:
Any way I can get this working? I have a block of code: <p><a
What is the best way to separate rendering code from the actually game engine/logic
Any way to make a OS X Finder like but valid XHTML/CSS search textfield
What way makes the most sense? I have a ASP.NET app... and maybe a
I need to pre-produce a million or two PDF files from a simple template
We have an app that allows users to send e-mails from our system. It
Is there a way using IoC, MEF [Imports], or another DI solution to compose
I want to compose application build version that is automatically derived from the Git
I am looking for a very quick way to render dynamic images from small

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.