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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T00:25:44+00:00 2026-06-13T00:25:44+00:00

Unfortunately i have lost the link and the source for this article, but I

  • 0

Unfortunately i have lost the link and the source for this article, but I do remember that it was about metaprogramming and templates in C++; when talking about the limitations around the template approach, this article was speaking about the fact that what is passed to a template it’s not a generic type, but only types with a related address ( or addressable, I don’t remember the exact words ) can be passed as arguments to a template.

Can someone clarify this relation between addresses, types and templates ?

A type can be identified with an address ?


EDIT

for example at this link, in the last part of the linked FAQ, the template system is described like something that takes an address rather than a generic type.

  • 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-06-13T00:25:46+00:00Added an answer on June 13, 2026 at 12:25 am

    I don’t know about the original article you read, but the FAQ you linked to in the edit does not talk about a connection between types and addresses.

    It talks about one specific kind of template parameters, the non-type parameters. There are three kinds of template parameters: type, non-type and template. So this is specifically about the second kind.

    An example of a non-type parameter is Id in the definition below:

    template <const char *Id>
    struct C
    {};
    

    Id does not represent a type, but a non-type, i.e. an actual value. In this particular example, that value happens to be of a a pointer type, and it represents the address of a string.

    The idea is that you can use this to instantiate the template using a string as distinguisher:

    C<"foo"> c1;  // Instantiating the "foo" version of type C
    C<"bar"> c2;  // Instantiating the "bar" version of type C
    

    Unfortunately, it does not work like this – and that is what the FAQ article is about. It explains that for a non-type template parameter, you must use a constant expression, and in this particular case, you must use an identifier of an object with external linkage, not just a literal. So the only way you can do it is this:

    template <const char *Id>
    struct C
    {
    
    };
    
    char id1[] = "foo";
    char id2[] = "bar";
    
    int main()
    {
      C<id1> c1;
      C<id2> c2;
      /*...*/
      return 0;
    }
    

    That is what the FAQ article explains.

    However, again, this is a very special case, because it applies to non-type parameters of an address type only. Note that the connection to addresses is given because the non-type parameter is explicitly specified as a parameter of pointer type const char *.

    Most usual templates arguably use either a type-parameter or a non-type parameter of an integral, enum, or user-defined type. None of those has anything to do with memory addresses. There is no implicit connection between using templates and using memory addresses.

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

Sidebar

Related Questions

I see that this has been asked many times. But, unfortunately I have not
I have a jar file but unfortunately I lost source code due to my
Unfortunately I don't have access to JQuery and all it's nicety. But I do
I have two carousels on one page but unfortunately they copy each other. http://jsfiddle.net/seanjacob/tB6y5/
I have a Unix timestamp that comes from a database that is (unfortunately) in
I have a website that runs on ASP.NET 4.0. Unfortunately people with Android phones
I have a database which I used to install joomla 1.7. Unfortunately I lost
I have a project that is source controlled using TFS. I was doing some
Unfortunately I have a pretty bad understanding of how to properly set up threading.
Unfortunately I have to do some interaction with IBM's UniData database system. I am

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.