|
Boost Users : |
From: Stuart Dootson (stuart.dootson_at_[hidden])
Date: 2006-02-24 02:48:02
On 2/24/06, yinglcs2_at_[hidden] <yinglcs2_at_[hidden]> 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
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net