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