Boost logo

Boost Users :

From: yinglcs2_at_[hidden]
Date: 2006-02-22 14:48:50


I have this compile error:
I did this:

std::for_each(map.begin(), map.end(),
    bind( &BlockList::sortY, this,
*bind(&MyMap::value_type::second,
 _1)));

../BlockList.cpp:769: error: no matching function for
call to ‘bind(<unknown type>, const BlockList*
const, const
boost::lambda::lambda_functor<boost::lambda::lambda_functor_base<boost::lambda::other_action<boost::lambda::contentsof_action>,
boost::tuples::tuple<boost::lambda::lambda_functor<boost::lambda::lambda_functor_base<boost::lambda::action<2,
boost::lambda::function_action<2,
boost::lambda::detail::unspecified> >,
boost::tuples::tuple<BlockDataList* std::pair<const
std::pair<int, int>, BlockDataList*>::* const, const
boost::lambda::lambda_functor<boost::lambda::placeholder<1>
>, boost::tuples::null_type, boost::tuples::null_type,
boost::tuples::null_type, boost::tuples::null_type,
boost::tuples::null_type, boost::tuples::null_type,
boost::tuples::null_type, boost::tuples::null_type> >
>, boost::tuples::null_type, boost::tuples::null_type,
boost::tuples::null_type, boost::tuples::null_type,
boost::tuples::null_type, boost::tuples::null_type,
boost::tuples::null_type, boost::tuples::null_type,
boost::tuples::null_type> > >)’
make: *** [BlockList.o] Error 1

--- Kevin Heifner <heifner_k_at_[hidden]> wrote:

> yinglcs2_at_[hidden] wrote:
> > I have a for loop which pass the map.second to a
> > function, like this:
> > class A;
> > typedef map<int, A*> MyMap;
> >
> > sortY(A& a);
> >
> > for (MyMap::iterator iter = map.begin(); iter !=
> > map.end(); ++iter) {
> > A *a = (*iter).second;
> >
> > sortY(*a);
> > }
> >
> > how can I translate the above for() loop into
> for_each
> > and use boost lambda?
>
> I didn't test the following, but it should work :)
>
> #include <boost/lambda/lambda.hpp>
> #include <boost/lambda/bind.hpp>
>
> using boost::lambda::_1;
> using boost::lambda::bind;
>
> std::for_each(map.begin(), map.end(),
> bind(&sortY, *bind(&MyMap::value_type::second,
> _1)));
>
> KevinH
> --
> Kevin Heifner heifner @ ociweb.com
> http://heifner.blogspot.com
> Object Computing, Inc. (OCI)
> www.ociweb.com
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
>
http://lists.boost.org/mailman/listinfo.cgi/boost-users
>

__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com


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