Generally speaking, if we provide a framework and accept the exterior defined actions. like this.
Code:
template<typename Iterator, typename Functor>
Functor for_each(Iterator beg, Iterator end, Functor fn)
{
    for(Iterator i = beg; i != end; ++i)
        fn(*i);
    return fn;
}
In fact, we don't care whether fn is a function or function object, also don't care what fn does. And the user who calls for_each() should give a function or a object which can be applyed through function-call syntax.