STL algorithms vs plain code
I have a vector of objects:

    std::vector<Object> data;

Now I need to call `Object::Foo()` in data array:

    for (int i=0; i < data.size(); ++i) data[i].Foo(); // I think, the most slower
    for (Object *it : data) it->Foo(); // And these are equal?
    for (auto it=data.begin(); i!=data.end(); ++it) it->Foo();

I know about these methods, but now I'm learning STL and I found `for_each` there:

    for_each(data.begin(), data.end(), mem_fun(&Object::Foo));

Which one is better? In other words, first 2 examples are more 'base' and it's easy to understand that constructions for common developer.

What about the speed of STL algorithms (and `for_each` with `mem_fun` in current case). Do I really need to learn it?
STL algorithms vs plain code
===

I have a vector of objects:

    std::vector<Object> data;

Now I need to call `Object::Foo()` in data array:

    for (int i=0; i < data.size(); ++i) data[i].Foo(); // I think, the most slower
    for (Object *it : data) it->Foo(); // And these are equal?
    for (auto it=data.begin(); i!=data.end(); ++it) it->Foo();

I know about these methods, but now I'm learning STL and I found `for_each` there:

    for_each(data.begin(), data.end(), mem_fun(&Object::Foo));

Which one is better? In other words, first 2 examples are more 'base' and it's easy to understand that constructions for common developer.

What about the speed of STL algorithms (and `for_each` with `mem_fun` in current case). Do I really need to learn it?