ALL,
Consider following code:
class CPlayer
{
public:
CPlayer(bool new) { m_new = new; };
bool IsNewPlayer() { return m_new; }
private:
bool m_new;
};
int main()
{
std::vector<CPlayer> players_pool;
players_pool.push_back( false );
players_pool.push_back( false );
players_pool.push_back( true );
players_pool.push_back( false );
}
Now what I'm looking for is to remove the players which has m_new as true.
Is it possible to do something like this:
players_pool.erase( std::remove( players_pool.begin(), players_pool.end(), players_pool.at().IsNewPlayer() ), players_pool.end() );
Now everywhere the examples given are for simple integers and not for the class objects.
Is there an easy way to perform such an operation?
And I need it to work in MSVC 2010 and XCode 4 with 10.6 SDK.
Note: The code given is a simplified version of the actual code I'm working on. Class CPlayer has a lot more fields than I put here but they are not relevant to this post.
Thank you.
P.S.: I found this but my question here is if it will work on OSX. My remover looks like this:
struct Remover : public std::binary_function<CPlayer,void,bool>
{
public:
bool operator()(const CPlayer &player) const
{
return player.IsNewPlayer();
}
};