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_REPLACE_HPP
00008 #define INSTIGATE_STL_REPLACE_HPP
00009
00058
00059 #include "concept.hpp"
00060 #include "_basis.hpp"
00061
00062
00063 #include <generic/base.hpp>
00064
00065
00066
00067
00068 namespace instigate {
00069 namespace stl {
00070 template <typename F, typename T>
00071 inline void replace(F, F, const T&, const T&);
00072 }
00073 }
00074
00109 template <typename F, typename T>
00110 inline void instigate::stl::replace(F f, F l, const T& o, const T& n)
00111 {
00112 CHECK(instigate::stl::writable_iterator::requirements<F>);
00113 CHECK(instigate::stl::forward_iterator::requirements<F>);
00114 CHECK(instigate::generic::assignable::requirements<T>);
00115 CHECK(instigate::generic::equality_comparable::requirements<T>);
00116 CHECK_CONVERTIBILITY(T, typename instigate::stl::writable_iterator::
00117 interface<F>::value_type);
00118 for ( ; !equal(f, l); increment(f)) {
00119 if (equal(const_dereference(f), o)) {
00120 dereference_assign(f, n);
00121 }
00122 }
00123 }
00124
00125
00126
00127 #endif // INSTIGATE_STL_REPLACE_HPP