
Cannot figure out how to properly use lambda library in following situation (pseudo-code below): class Unit { }; class Test { public: void dosmth(Unit* unit) {} }; int main() { vector<Unit*> lst; Test t; for_each (lst.begin(), lst.end(), ?// I want to call t.dosmth with each Unit* in list } Any help will be greatly appreciated.

----- Original Message ----- From: "QPlace" <quiteplace@mail.ru> To: <boost-users@lists.boost.org> Sent: Saturday, December 13, 2008 5:19 AM Subject: [Boost-users] Confused with Lambda library usage
Cannot figure out how to properly use lambda library in following situation (pseudo-code below):
class Unit { };
class Test { public: void dosmth(Unit* unit) {} };
int main() { vector<Unit*> lst; Test t; for_each (lst.begin(), lst.end(), ?// I want to call t.dosmth with each Unit* in list }
Any help will be greatly appreciated.
Hi, you can take a look at the documentation Lambda expressions in details > Member functions as targets Best, Vicente

Thank you Vicente, I already did and in spite of existence of the docs I had to ask for a help. All options that I came up with failed to compile. I can post them here, but I thought that for the person who knows Lambda library the answer should be trivial.

----- Original Message ----- From: "QPlace" <quiteplace@mail.ru> To: <boost-users@lists.boost.org> Sent: Saturday, December 13, 2008 3:18 PM Subject: Re: [Boost-users] Confused with Lambda library usage
Thank you Vicente,
I already did and in spite of existence of the docs I had to ask for a help. All options that I came up with failed to compile. I can post them here, but I thought that for the person who knows Lambda library the answer should be trivial.
Try, we will see. Vicente

On Sat, 13 Dec 2008 05:19:07 +0100, QPlace <quiteplace@mail.ru> wrote:
Cannot figure out how to properly use lambda library in following situation (pseudo-code below):
class Unit { };
class Test { public: void dosmth(Unit* unit) {} };
int main() { vector<Unit*> lst; Test t; for_each (lst.begin(), lst.end(), ?// I want to call t.dosmth with each Unit* in list }
for_each(lst.begin(), lst.end(), boost::lambda::bind(&Test::dosmth, boost::ref(t), boost::lambda::_1)); HTH, Boris
participants (3)
-
Boris
-
QPlace
-
vicente.botet