
On 2/24/06, yinglcs2@yahoo.com <yinglcs2@yahoo.com> wrote:
Hi,
I have the code which copy from a STL list to another if a condition is met:
list<A*> alist;
for (list<A*>::iterator iter = alist.begin(); iter != alist.end(); ++iter) {
A* a = (*iter);
if ( a->aFunc( i, j) { destList.push_back(a); } }
I try doing this, but it does not compile:
for_each(alist.begin(), alist.end(), if_then( bind(&A::aFunc, _1 , i, j ), columnBlocks.push_back(_1)));
There are my errors:
error: no matching function for call to 'std::vector<A*, std::allocator<A*>
::push_back(const boost::lambda::lambda_functor<boost::lambda::placeholder<1> &) error: 'if_then' was not declared in this scope
1. Have you included the correct header (boost/lambda/if.hpp). 2. You'll have to bind the push_back call as well: bind(&list<A*>::push_back, columnBlocks, _1) HTH Stuart Dootson