loop -> for_each

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • ibe

    #1

    loop -> for_each

    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(l ist_.begin(), list_.end(),
    bind(mem_fun(&F oo::accept), _1, v));

    fine!
    But now things changed to something like

    std::deque<boos t::sha
Working...