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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T03:39:05+00:00 2026-05-11T03:39:05+00:00

When declaring a template, I am used to having this kind of code: template

  • 0

When declaring a template, I am used to having this kind of code:

template <class T> 

But in this question, they used:

template <unsigned int N> 

I checked that it compiles. But what does it mean? Is it a non-type parameter? And if so, how can we have a template without any type parameter?

  • 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. 2026-05-11T03:39:06+00:00Added an answer on May 11, 2026 at 3:39 am

    It’s perfectly possible to template a class on an integer rather than a type. We can assign the templated value to a variable, or otherwise manipulate it in a way we might with any other integer literal:

    unsigned int x = N; 

    In fact, we can create algorithms which evaluate at compile time (from Wikipedia):

    template <int N> struct Factorial  {      enum { value = N * Factorial<N - 1>::value }; };  template <> struct Factorial<0>  {     enum { value = 1 }; };  // Factorial<4>::value == 24 // Factorial<0>::value == 1 void foo() {     int x = Factorial<4>::value; // == 24     int y = Factorial<0>::value; // == 1 } 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This problem is in defining and declaring a function template in a namespace that
a template parameter can be used in another template parameter that follows it this
I was struggling with the issue described in this question (declaring a template function
In a question about forward declaring templates, and an answer that this is not
I'm having trouble declaring a template class. I've tried an number of ill-readable and
Can anyone tell what is wrong with this piece of code? template<class X> class
I am successfully declaring a data template in a code behind as follows: private
I know this is probably a dumb question but I can't figure it out
I have a control template defined, call it myVal, that is used for validation
Possible Duplicate: What does template <unsigned int N> mean? Hi ! Are non-type template

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.