ProjectileManager inherits from EntityManager, which has this as a protected member:
struct EntityDeallocator{
void operator()(std::pair<sf::String,std::shared_ptr<Entity>> p)const{
p.second.reset();
std::cout << "object removed" << std::endl;
}
};
The ProjectileManager update function:
void ProjectileManager::update(double frameTime){
for(std::map<sf::String,std::shared_ptr<Entity>>::const_iterator it = entities.begin();it!=entities.end();it++){
it->second->update(frameTime);
it->second->getObject()->draw(*SfmlFramework::Singleton()->window);
if(it->second->getObject()->getSprite()->GetPosition().x > SfmlFramework::Singleton()->window->GetWidth() || it->second->getObject()->getSprite()->GetPosition().y > SfmlFramework::Singleton()->window->GetHeight()){
//I want to call EntityDeallocator on it
}
}
}
How would I call EntityDeallocator on it? I have tried EntityDeallocator(it) but that says it is an unreferenced local variable.
Says what is an unreferenced local variable? Post your error strings, not your approximation of the error strings..
As for how to call a non-static member function, they are always the same. You need a member function, and an object to bind it to.
Although not directly pertinent to your question, you may find this link very helpful for understanding how C++ calls member functions. http://www.parashift.com/c++-faq-lite/pointers-to-members.html