模板定义:
template <typename UnaryFunction, typename ContextAcessor>
void ForEachApplication(UnaryFunction func) {
using namespace utils;
typename ContextAcessor::ApplicationListAccessor accessor;
typedef typename ContextAcessor::ApplictionSetConstIt Iter;
for (Iter it = accessor.begin(); it != accessor.end(); ++it) {
if (it->valid()) {
ApplicationConstSharedPtr const_app = *it;
func(ContextAcessor::instance()->application(const_app->app_id()));
}
}
}
模板调用:
void StateController::TempStateStopped(HmiState::StateID ID) {
LOG4CXX_AUTO_TRACE(logger_);
{
sync_primitives::AutoLock autolock(active_states_lock_);
active_states_.remove(ID);
}
ForEachApplication(std::bind1st(std::mem_fun(&StateController::ApplyPostponedStateForApp), this));
}
编译错误:
error C2783: 'void application_manager::StateController::ForEachApplication(UnaryFunction)' : could not deduce template argument for 'ContextAcessor'
编译环境:win7_x64+vs2008
请大神帮帮忙,怎么解决啊~~~