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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T21:07:03+00:00 2026-06-08T21:07:03+00:00

For my program i need to define a Solver class which can either solve

  • 0

For my program i need to define a Solver class which can either solve a problem or nested problem.

template< typename ProblemT >
struct Solver {
    static void a() {
        ProblemT::func();
    }
};

template< typename < typename SubT> ProblemT >
struct Solver<ProblemT< SubT> > {
    static void a() {
        ProblemT::func();
        SubT::func();
    }
};

Usage:

Solver<Problem1> solver;
Solver<Problem2<Problem3> > nested_solver;

In the specialized version of Solver i need to know both ProblemT and SubT types in order to define the types correctly and call the correct functions.

Is there just a simple error or is it impossible to define such a class?

  • 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-08T21:07:05+00:00Added an answer on June 8, 2026 at 9:07 pm

    You can try something like this:

    template <typename T>
    struct Solver
    {
        static void solve() { T::func(); }
    };
    
    template <template <typename> class Tmpl, typename U>
    struct Solver<Tmpl<U>>
    {
        static void solve() { Tmpl<U>::solve(); }
    };
    

    Obviously, you can decorate your primary Solver template with further member functions which you can access in the specialization, etc.

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

Sidebar

Related Questions

I need user to define all the environment variables needed for my program in
I need my program to create and edit a config file, which would contain
on more than one occasion I felt the need to define class methods that
I need some help with a program I'm writing for my Programming II class
I need to run a programe before knowing which suit of test(define in testng.xml)
I need help access global functions across DLLs/main program. I have a class Base
I wrote a Haskell code which has to solve the following problem : we
in a C program I need to define float (*d_i)[3]; but later I realized
In my program I need to programmatically configure an ApplicationContext. Specifically, I have a
In my program I need a way to click on an Image control, the

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.