loop -> for_each

I

ibe

Hi,
i can't get the clue:
I have had a loop in my code like this:

---snip---

class Foo {
accept(Visitor& v) {
v.visit(*this);
}
};

class Visitor {
visit (Foo& f) {
...
}
}

....in main...

Visitor v(arugments, ...);
for (std::deque<Foo*>::iterator iter = list_.begin();
iter != m_list.end();
++iter) {
(*iter)->accept(v);
}

---snip---

by means of the boost::bind i could express the loop with

std::for_each(list_.begin(), list_.end(),
bind(mem_fun(&Foo::accept), _1, v));

fine!
But now things changed to something like

std::deque<boost::sha
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top