00001
00002 #ifndef _INSTIGATE_STL_INTERNAL_HEADER_IN_ALGORITHM
00003 #error This is an internal header file used to implement Instigate STL.\
00004 It should never be included directly by a program.
00005 #endif
00006
00007 #ifndef INSTIGATE_STL_FOR_EACH_HPP
00008 #define INSTIGATE_STL_FOR_EACH_HPP
00009
00057
00058 #include "concept.hpp"
00059 #include "functor.hpp"
00060 #include "_basis.hpp"
00061
00062
00063
00064
00065
00066
00067 namespace instigate {
00068 namespace stl {
00069 template <typename I, typename UF>
00070 UF for_each(I b, I e, UF f);
00071 }
00072 }
00073
00093 template <typename I, typename UF>
00094 inline UF instigate::stl::for_each(I b, I e, UF f)
00095 {
00096 typedef instigate::stl::unary_function::interface<UF> UFI;
00097 namespace SP = instigate::stl::single_pass_iterator;
00098 namespace RI = instigate::stl::readable_iterator;
00099 CHECK(instigate::stl::unary_function::requirements<UF>);
00100 CHECK(SP::requirements<I>);
00101 CHECK(RI::requirements<I>);
00102 while (!equal(b, e)) {
00103 invoke(f, const_dereference(b));
00104 increment(b);
00105 }
00106 return f;
00107 }
00108
00109
00110
00111 #endif // INSTIGATE_STL_FOR_EACH_HPP