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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T17:39:55+00:00 2026-05-23T17:39:55+00:00

Ok, I don’t know if the title made much sense, so I will just

  • 0

Ok, I don’t know if the title made much sense, so I will just show the code:

template <class S,class P,class A> class Task
{
  protected:

    timeval start;
    boost::ptr_vector<S> states;
    boost::ptr_vector<P> policies;
    Agent &robot;
    const ACTION_MODE &a_mode;
    A algo;

  public:

    Task(Agent &a, ACTION_MODE &m, A &alg) : robot(a), a_mode(m), algo(alg) {};
    P* findPolicy(S *state);
    bool stateExists(S *state);
    bool if_appendState(S *state);
    bool policyExists(P *policy);
    bool if_appendPolicy(P *policy);  
    void run();
};

Class S, is for States (a polymorphic class ) class P is for policies (a templated polymoprhic class) and class A is for Algorithm classes.
For example (a class A – type):

class SarsaTD
{
  protected:
    const float gamma;
    const float alpha;
    PTYPE method;
  public:
    SarsaTD(float a, float g) : alpha (a), gamma (g) {method = ON_POLICY; };
    template <typename P> void optimize(P *policy);
    PTYPE getType();
};

I am trying to use from class Task’s parameter P (policies) and forward it into a method of an instance of SarsaTD.

template <class S,class P,class A> void Task<S,P,A>::run()
{
  S *state = new S(Task<S,P,A>::robot, const_cast<ACTION_MODE&>(Task<S,P,A>::a_mode));
  P *policy;
  if (Task<S,P,A>::if_appendState(state))
  {
    policy = new P(state);
    Task<S,P,A>::if_appendPolicy(policy);
  }
  else
  {
    policy = Task<S,P,A>::findPolicy(const_cast<S *>(state));
    policy->getValue();
    delete state;
  }

  Task<S,P,A>::algo.optimize<P>(policy);
  wb_robot_step(TIME_STEP);
}

Everythign works fine, untill the line: Task<S,P,A>::algo.optimize<P>(policy);
Where the compiler gives the following error:

task.hpp:174: error: expected-primary expression before '>'token

If I understand this correctly, the Parameter type P (policy) I use throughout the template class cannot be forwarded properly into the template function ?
Or is my syntax wrong ? Or what I am trying to do simply makes no sense ?

  • 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-23T17:39:55+00:00Added an answer on May 23, 2026 at 5:39 pm
    Task<S,P,A>::algo.optimize<P>(policy);
    

    At that point it can’t know whether optimize is a value or not. You’ll understand if you just look at

    Task<S,P,A>::algo.optimize < P
    

    This not only looks like a comparison to you, but also to the compiler. Even if it then proceeds with parsing, it can’t know whether your intention was a comparison or a template argument list, unless it fully instantiates the template type. If you search for “dependent name” and “two phase lookup”, you’ll find some useful information. The solution in your case would be manual disambiguation. Tell the compiler that optimize is a template:

    Task<S,P,A>::algo.template optimize<P>(policy);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

don't know better title for this, but here's my code. I have class user
I don't really know too much about core JavaScript, just a dot of jQuery.
Don't be scared of the extensive code. The problem is general. I just provided
Don't really know how to formulate the title, but it should be pretty obvious
I don't know if the correct title for this is hot deploy. I am
Don't be frightened, its a very basic code. Just wanted to check with you
Don't know much about running a function on every item in an array, still
Don't know a better title but here is what im trying to do. I
Don't have much to say, just can get into the event handler. XAML: <Grid>
Don't know if this is the right place to ask this, but I will

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.