|
Boost Users : |
From: Jeff Faust (jeff_at_[hidden])
Date: 2002-09-04 13:22:11
#include <boost/bind.hpp>
...
int updateVal;
...
for_each(blocks.begin(), blocks.end(), boost::bind(&Block::update, _1,
updateVal));
Jeff
-----Original Message-----
From: Mark Snelling [mailto:mark_at_[hidden]]
Sent: Wednesday, September 04, 2002 10:17 AM
To: Boost-Users_at_[hidden]
Subject: [Boost-Users] Newbie boost::mem_fn problem
Hello,
My problem I think is very simple, I just can't seem to find the solution
I have an STL list of object pointers and I want to call a member function
on each of the pointers in the list usigng the STL for_each algorithm. This
would seem easy if the list contained the actual objects rather than
pointers to them, but because they are pointers I can't find a way of doing
this.
class Block
{
public:
void update(int x);
};
void main()
{
list<Block*> blocks;
for_each(blocks.begin(), blocks.end(), *****); // Call update on each
item in list
}
what should I replace the ***** with?
Any help appreciated!
Mark.
Info: <http://www.boost.org>
Wiki: <http://www.crystalclearsoftware.com/cgi-bin/boost_wiki/wiki.pl>
Unsubscribe: <mailto:boost-users-unsubscribe_at_[hidden]>
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
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