M
Michael
Hi,
I am having some problems with for_each:
class Universe
{
public:
bool CheckIsValidImprovement( Improvement* );
bool ValidateTech();
list<TechImprovement> techImprovements
};
class Improvement
{
};
class TechImprovement : public Improvement
{
};
I have written a
bool Universe::ValidateTech()
{
for( it = techImprovements.begin(); it != techImprovements.end();it++)
if( ! CheckIsValidImprovement(&(*it)) ) return false;
return true;
}
but I'd like to write it as a for_each or a find_if for practice but am
struggling with the error msgs!
find_if( techImprovements.begin(),
techImprovements.end(),
ptr_fun( &CheckIsValidImprovement ) );
can't use it because its a member function.
how is this problem normally solved? do you need bind second to the Universe
using a this pointer? Have I got the wrong end of the stick??
Regards
Mike
I am having some problems with for_each:
class Universe
{
public:
bool CheckIsValidImprovement( Improvement* );
bool ValidateTech();
list<TechImprovement> techImprovements
};
class Improvement
{
};
class TechImprovement : public Improvement
{
};
I have written a
bool Universe::ValidateTech()
{
for( it = techImprovements.begin(); it != techImprovements.end();it++)
if( ! CheckIsValidImprovement(&(*it)) ) return false;
return true;
}
but I'd like to write it as a for_each or a find_if for practice but am
struggling with the error msgs!
find_if( techImprovements.begin(),
techImprovements.end(),
ptr_fun( &CheckIsValidImprovement ) );
can't use it because its a member function.
how is this problem normally solved? do you need bind second to the Universe
using a this pointer? Have I got the wrong end of the stick??
Regards
Mike