I am sorry that I did not figure out the whole intention. Beside calling member function, I hope to delete the object immediately.
I wrote the code at first time:
std::for_each( items.rbegin(), items.rend(), (_1->*&DiscardableItem::Discard, bind(delete_ptr(), _1)) );
after for_each, objects deleted, but Discard function did not been called.
If using Bind can do the same thing, please tell me. thanks!
2009/3/23 Alex MDC
<alex.mdc@gmail.com>
But DiscardableItem::Discard does not be called. How can I make it work? thanks! I think lambda can solve this problem easily.
You don't need boost::lambda here, you can easily solve this with boost::bind
std::for_each( items.rbegin(), items.rend(), boost::bind(&DiscardableItem::Discard, _1) );
If you *want* to use boost::lambda I'm sure someone else will help :)
Regards,
Alex
_______________________________________________
Boost-users mailing list
Boost-users@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users