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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T16:10:01+00:00 2026-06-07T16:10:01+00:00

Given a template metaprogram (TMP), do C++ compilers produce build statistics that count the

  • 0

Given a template metaprogram (TMP), do C++ compilers produce build statistics that count the number of instantiated classes? Or is there any other way to automatically get this number? So for e.g. the obiquitous factorial

#include <iostream>

template<int N> struct fact { enum { value = N * fact<N-1>::value }; };
template<> struct fact<1> { enum { value = 1 }; };

int main()
{
    const int x = fact<3>::value;
    std::cout << x << "\n";
    return 0;
}

I would like to get back the number 3 (since fact<3>, fact<2>, and fact<1> are instantiated). This example if of course trivial, but whenever you start using e.g. Boost.MPL, compile times really explode, and I’d like to know how much of that is due to hidden class instantiations. My question is primarily for Visual C++, but answers for gcc would also be appreciated.

EDIT: my current very brittle approach for Visual C++ is adding the compile switch from one of Stephan T. Lavavej’s videos /d1reportAllClassLayout and doing a grep + word count on the output file, but it (a) increases compile times enormously and (b) the regex is hard to get 100% correct.

  • 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-07T16:10:03+00:00Added an answer on June 7, 2026 at 4:10 pm

    I made a one-line change to GCC that makes it print out the name of each class template as it instantiates it. You can already call the C++ front-end cc1plus directly without the -quiet flag to get the same for function templates.

    I haven’t got round to turning that into a proper GCC option yet, it’s just a hack on my own source tree. I’m thinking of implementing it as a plugin instead, but it’s not near the top of my TODO list.

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

Sidebar

Related Questions

Given: template <int N> struct val2size { char placeholder[N]; }; Is there any guarantee
Given that sorl isn't an app directory wide and the template tag definition lives
In C++, I have a certain template function that, on a given condition, calls
Given a template function, that does not use the template parameter for input directly.
In the context of Apache's Velocity, 1) Is there any way to, given a
Given a yaml file that contains html , like this: template : |+ <div>Hello,
Is there any way of creating a function that accepts any version of a
I'm currently writing a process that generates Powerpoint reports programmatically from a given template
Given: template<class T> struct test { void foo(int b); void testFunc( int a )
Given a template template <int n> void f(){...}; I know I can specialize it

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.