M
Michael Hull
Hi, I know this really shouldn't be that difficult, bt I can't work it
out:
class A
{
public:
/* Class Definition*/
};
class B
{
list< boost::shared_ptr<A> > aList;
public:
void DoA( boost::shared_ptr<A> a ) {/* */ }
void DoAll()
{
list<A>::iterator it;
for(it = aList.begin();it !=aList.end();it++)
DoA(*it);
}
};
now i have code similar to this, but I am trying to replace it with a
for_each line.
for_each( aList.begin(),aList.end(), ????)
And this is where I am having a problem, if DoA were a free function,
it would be no problem, i could use ptr_fun, but I can't work out how
to associate the 'this' instance with the member function to create a
functor!
Many thanks in advance
Mike
out:
class A
{
public:
/* Class Definition*/
};
class B
{
list< boost::shared_ptr<A> > aList;
public:
void DoA( boost::shared_ptr<A> a ) {/* */ }
void DoAll()
{
list<A>::iterator it;
for(it = aList.begin();it !=aList.end();it++)
DoA(*it);
}
};
now i have code similar to this, but I am trying to replace it with a
for_each line.
for_each( aList.begin(),aList.end(), ????)
And this is where I am having a problem, if DoA were a free function,
it would be no problem, i could use ptr_fun, but I can't work out how
to associate the 'this' instance with the member function to create a
functor!
Many thanks in advance
Mike