如果标题描述性不够,我很抱歉,我不知道这有什么问题:
template <class S, class P>
P* findPolicy(boost::ptr_vector<P> &policies,S *state)
{
typename boost::ptr_vector<P>::iterator it;
for ( it = policies.begin(); it != policies.end(); ++it)
{
if ( *it->getState() == state)
{
return &(*it);
}
}
}
当我从以下成员函数中调用上述函数时:
template <class S> template <class P>
void Policy<S>::updateOptimal(boost::ptr_vector<P> &policies)
{
S *curr_state = state;
boost::ptr_vector<Action> actions = curr_state->getAllActions();
P *best_pol;
boost::ptr_vector<Action>::iterator iter;
for (iter = actions.begin(); iter != actions.end(); ++iter)
{
if (iter->getNextState())
{
S *s = dynamic_cast<S *>(iter->getNextState());
P *temp_pol = var::findPolicy<S,P>(policies,s);
if (temp_pol->getValue() > best_pol->getValue())
{
opt_Action = &(*iter);
}
}
}
}
我总是得到:
policy.hpp:237: error: no matching function for call to 'findPolicy(boost::ptr_vector<Greedy<guState>, boost::heap_clone_allocator, std::allocator<void*> >&, State*&)