I've got two member functions:
//Particle.h
class Particle
{
public:
bool isDead()const;
static bool isDead(const Particle & par);
};
//Particle.cpp
bool Particle::isDead()const
{
return(xPos<=0 || xPos>=SCREEN_WIDTH || yPos<=0 || yPos>=GRASS_HEIGHT);
}
bool Particle::isDead(const Particle & par)
{
return(par.xPos<=0 || par.xPos>=SCREEN_WIDTH || par.yPos<=0 || par.yPos>=GRASS_HEIGHT);
}
But when a try to use the other function as a predicate for a remove_if call, I get an ambiguity error.
//Cursor.cpp
//The statement that causes the error
particleContainer.remove_if(Particle::isDead);
1>c:\users\eric\documents\visual studio 2008\projects\duck hunt\duck hunt\cursor.cpp(174) : error C2914: 'std::list<_Ty>::remove_if' : cannot deduce template argument as function argument is ambiguous
1> with
1> [
1> _Ty=Particle
1> ]
1>c:\users\eric\documents\visual studio 2008\projects\duck hunt\duck hunt\cursor.cpp(174) : error C2784: 'void std::list<_Ty>::remove_if(_Pr1)' : could not deduce template argument for 'overloaded function type' from 'overloaded function type'
1> with
1> [
1> _Ty=Particle
1> ]
1> c:\program files\microsoft visual studio 9.0\vc\include\list(944) : see declaration of 'std::list<_Ty>::remove_if'
(particleContainer is a list of Particles(list<Particle> particleContainer))
I can't see the ambiguity in this statement. What am I doing wrong?