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

  • Home
  • SEARCH
  • 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 6368789
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T00:43:13+00:00 2026-05-25T00:43:13+00:00

I am trying to create a lightweight template class having a static member initialized

  • 0

I am trying to create a lightweight template class having a static member initialized with the value provided as template argument( only enum are alowed ).

The code below doesn’t build saying

   error: wrong number of template arguments (1, should be 2)
   error: provided for ‘template<field_id field_value, 
   inner_type_id innter_type_value>     struct node’
   error: template declaration of ‘field_id m_field_id’

The problem seems the first template argument. If I remove ‘field_value’ and ‘inneer_type_value’ still doesn’t build saying mismatch error.

Can you help me ?
Thanks AFG

   enum field_id{ FIELD_ID_1, FIELD_I_2  };
   enum inner_type_id{ INN_ID_1, INN_ID_2  };

    template< enum field_id  field_value
            , enum inner_type_id inner_type_value 
    >struct node{
            static field_id m_field_id;
    };

    template< 
            enum field_id  field_value
            ,enum inner_type_id inner_type_value 
    >
    enum field_id node<
            enum field_id field_value
            ,enum inner_type_id inner_type_value
    >::m_field_id=field_value;

    int main(){
           node<FIELD_ID_1,INN_ID_1> obj;
           assert( obj::m_field_value == FIELD_ID );
    }

I am also tyring another different approach, but still I don’t get it

         template< typename T1, typename T2 >
         struct node;

         template<>
         struct node< enum field_id=FIELD_ID_1, enum inner_type_id=INN_ID_1>{
              static enum field_id m_field_id;
         };             
         note< 
               enum field_id=FIELD_ID_1
              ,enum inner_type_id=INN_ID_1
              >::m_field_id=FIELD_ID1;
  • 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-25T00:43:13+00:00Added an answer on May 25, 2026 at 12:43 am

    In the end your code probably should look like:

    enum field_id{ FIELD_ID_1, FIELD_I_2  };
    enum inner_type_id{ INN_ID_1, INN_ID_2  };
    
    template<field_id  field_value, inner_type_id inner_type_value>
    //       ^ no enum keyword
    struct node
    {
      static field_id m_field_id;
    };
    
    template<field_id  field_value, inner_type_id inner_type_value>
    field_id node<field_value, inner_type_value>::m_field_id = field_value;
    //            ^ no enum and type
    
    int main(){
      typedef node<FIELD_ID_1,INN_ID_1> my_type;
      assert( my_type::m_field_id == FIELD_ID_1 );
      //               ^ there's only m_field_id member
      my_type obj;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to create my own sort of lightweight,yet OOP way to keep
I'm trying to create a new partition in the root of a ApacheDS Lightweight
I am trying create a simple WQL query where I only return mounted drives
I'm trying to create a lightweight code for button clicks, so with the help
I am trying to perform a lightweight migration, but I am having a problem
I'm trying to create a lightweight, self-contained webservice using the spark microframework ( http://www.sparkjava.com/readme.html
A little background: I am trying to create a lightweight cookieless database-backed user session
I am trying create a WCF service that leverages the WPF MediaPlayer on the
I'm trying create a bot which automatically likes Facebook posts. Using Mechanize I can
I am trying create a delegate representation of constructor by emitting a Dynamic Method,

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.