template<typename Iterator>void func(Iterator begin, const Iterator end){ for (; end != begin; ++begin) // do something with *begin}std::vector<int> v;func(v.begin, v.end);func(v.rbegin, v.rend);