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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T02:26:07+00:00 2026-06-18T02:26:07+00:00

I am using template metaprogramming in c++ to generate a hierarchy of classes from

  • 0

I am using template metaprogramming in c++ to generate a hierarchy of classes from using a typelist like so:

//! Basic typelist class
template<class H, class T>
class Typelist
{
public:
    typedef H Head;
    typedef T Tail;
};

//! Terminating type
class NullType {};

//! Forward declaration
template<class Types>
class Recur;

//! Specialisation to terminate the recursion
template<>
class Recur<NullType>
{
};

//! General recursive class 
template<class Types>
class Recur: public Recur<typename Types::Tail>
{
};

// Dummy classes 
class Type1{};
class Type2{};
class Type3{};
int main()
{
    // Defines the typelist
    typedef Typelist<Type1,Typelist<Type2,Typelist<Type3,NullType>>> Types;

    // Instantiate the recursion
    Recur<Types> recur;
    return 1;
}

This would produce a class hierarchy like so:

Recur<Typelist<Type2,Typelist<Type3,NullType>>> which derives from:
Recur<Typelist<Type3,NullType>> which derives from:

Recur<NullType> (base class)

Question: Are there any Visual Studio 2010 compiler limits to the depth of class derivation using this recursive technique? In other words if my typelist contained N types would the code above compile and construct N classes even if N equals say 100,000?

  • 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-18T02:26:09+00:00Added an answer on June 18, 2026 at 2:26 am

    Annex B of the Standard specifies only a minimum level of direct and indirect base classes and nested template instantiations, and it’s a quality of implementation issue whether a specific compiler goes beyond that. Consult your specific compilers own documentation for the precies numbers. Below follow the minimum quantities required by the Standard.

    Annex B (informative)
    Implementation quantities [implimits]

    1 Because computers are finite, C++ implementations are inevitably
    limited in the size of the programs they can successfully process.
    Every implementation shall document those limitations where known.
    This documentation may cite fixed limits where they exist, say how to
    compute variable limits as a function of available resources, or say
    that fixed limits do not exist or are unknown.

    2 The limits may constrain quantities that include those described
    below or others. The bracketed number following each quantity is
    recommended as the minimum for that quantity. However, these
    quantities are only guidelines and do not determine compliance.

    — Direct and indirect base classes [16 384].

    — Direct base classes for a single class [1 024].

    — Recursively nested template instantiations, including substitution
    during template argument deduction (14.8.2) [1 024].

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

Sidebar

Related Questions

using template classes I usually make some typedefs like: typedef super<puper<complex<template<type> > > >
I am writing a very simple template class using Metaprogramming to compute sum in
I have a self-define class using template, like this: template<class T> class foo {
I am using template classes in c++. I create an object of the class
Starting with some metaprogramming code: template<class... Ts> class list {}; //a generic container for
Here's the code that I'm currently using template <class T> float Knapsack<T>::knapTable() { const
So I have a template class that I would like to accept an std::map
Why do we still use structures and typedef s (or using s) for metaprogramming?
Is there a way to by using some metaprogramming trick make situation like this
I'm using template functions for object construction to create objects from reflection data, and

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.