the implementation of for_each is something like

The C++ Standard declares std::for_each() as:

Code:

template<class InputIterator, class Function>
Function for_each(InputIterator first, InputIterator last, Function f);

The MinGW port of g++ 3.4.5 has an implementation that amounts to:

Code:

template<class InputIterator, class Function>
Function for_each(InputIterator first, InputIterator last, Function f)
{
for (; first != last; ++first)
{
f(*first);
}
return f;
}

So, operator(*A) of class Func will be invoked? Right?

Function::operator(InputIterator::value_type) is the overloaded operator that will be invoked.