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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T17:52:03+00:00 2026-05-15T17:52:03+00:00

I have that template class that uses a policy for it’s output and another

  • 0

I have that template class that uses a policy for it’s output and another template argument to determine the type for it’s data members. Furthermore the constructor takes pointers to base classes which are stored in private pointers. Functions of this objects shall take a this pointer to the template class to give them access to the data. In code this looks like this:

class ShapeGenerator;

template <typename PointData, typename OutputPolicy> class ModelCreator {
private:
    OutputPolicy output;
    ShapeGenerator* shape
    std::vector<PointData> data;
public:
    ModelCreator (ShapeGenerator *s) : shape(s) { }
    void createShape() { shape->generateShape(this); }
};

ShapeGenerator is an interface and shall be implemented. It looks like this:

class ShapeGenerator {
public:
    void generateShape (ModelCreator* m) = 0;
};

If I compile this with g++ 4.3.4 (cygwin) I get an error in the ShapeGenerator::generateShape saying 'ModelCreater' is not a type. I put in a forward declaration of ModelCreator but it changed nothing. I played with some combinations of types and parameters, for example passing only the vector and then I got an error message that said something about incomplete types. I guess this is the problem here.

So, is it possible to pass a templated type with without specific arguements? If so, how?

edit:
I’m not bound to the ModelCreator typename. If I have to write it more template-like this isn’t problem. But I would like not to specify the types of ModelCreator in the ShapeCreator object. Is that possible?

edit2:
Ok, I guess I was a bit to optimistic with this “design”. It would have been nice to just throw in some ingrediences and get a soup. But now the salt has to know about the kind of water in the pot. I’ll change the templates to plain old composition. Thanks you guys.

  • 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-15T17:52:03+00:00Added an answer on May 15, 2026 at 5:52 pm

    If you want to use the ModelCreator with “free” template parameters, then you have to make ShapeGenerator a template too:

    template <typename PointData, typename OutputPolicy> 
    class ShapeGenerator {
    public:
        void generateShape (ModelCreator<PointData,OutputPolicy>* m) = 0;
    };
    

    or

    template <template <typename, typename> class ModelCreator> 
    class ShapeGenerator {
    public:
        void generateShape (ModelCreator* m) = 0;
    };
    

    The second version takes another template as a parameter. You would use it like this:

    ShapeGenerator<ModelCreator<PointDataType,OutPutPolicyType> > shapeGenerator; 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

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.