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

The Archive Base Latest Questions

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

I am unable to compile the below program in VS2010. Keeps compiling endless and

  • 0

I am unable to compile the below program in VS2010. Keeps compiling endless and got into heap not available. Any help is much appreciated.

#include <iostream>

class function_t
{
public:
    virtual void operator ()()=0;
};

class greet_t : public function_t
{
public:
    virtual void operator()(){ std::cout << "hello world" << std::endl;}
};

template<int count, function_t** f> class loop_t
{
public:
    static inline void exec()
    {
        (*(*f))();
        loop_t< count-1, f>::exec();

    }
};

function_t* f;
int _tmain(int argc, _TCHAR* argv[])
{
    f = new greet_t();
    loop_t<1, &f>::exec();

    return 0;
}
  • 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-24T08:13:27+00:00Added an answer on May 24, 2026 at 8:13 am

    I believe the problem is in your template code:

    template<int count, function_t** f> class loop_t
    {
    public:
        static inline void exec()
        {
            (*(*f))();
            loop_t< count-1, f>::exec();
    
        }
    };
    

    Notice that you instantiate this inner template:

    loop_t< count-1, f>::exec();
    

    The problem is that you’ve never defined a partial specialization of loop_t that terminates when the loop counter reaches some value (say, zero), and so the compiler just keeps on instantiating more and more versions of loop_t with lower and lower values of count until it reaches an internal limit and reports an error. To fix this, you should introduce a partial specialization of loop_t to halt when the counter hits some value (probably zero):

    template<function_t** f> class loop_t<0, f>
    {
    public:
        static inline void exec()
        {
            // Empty
        }
    };
    

    Hope this helps!

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

Sidebar

Related Questions

Below program (a toy program to pass around arrays to a function) doesn't compile.
When I compile my application , I get following compile error. Unable to find
I'm trying to compile a Python binding, but I'm unable to find the python.h
Please see my code below. ifstream myLibFile (libs//%s , line); // Compile failed here
I am unable to print the euro symbol. The program I am using is
I've downloaded new Xcode 4.2 and I'm unable to compile the old projects since
Given the below program, I am having issues dealing with monads. module Main where
Symptoms : Any JSP pages in the project produce error messages as below: org.apache.jasper.JasperException:
I am compiling the code below when the following erro comes up. I am
All of a sudden I am unable to run any web application in Visual

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.