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_COPY_IF_HPP
00008 #define INSTIGATE_STL_REPLACE_COPY_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 I, typename O, typename P, typename T>
00072 inline O replace_copy_if(I, I, O, P, const T&);
00073 }
00074 }
00075
00119 template <typename I, typename O, typename P, typename T>
00120 inline O instigate::stl::replace_copy_if(I f, I l, O r, P p, const T& n)
00121 {
00122 CHECK(instigate::stl::single_pass_iterator::requirements<I>);
00123 CHECK(instigate::stl::readable_iterator::requirements<I>);
00124 CHECK(instigate::stl::incrementable_iterator::requirements<O>);
00125 CHECK(instigate::stl::writable_iterator::requirements<O>);
00126 CHECK(instigate::stl::unary_predicate::requirements<P>);
00127 CHECK(instigate::generic::assignable::requirements<T>);
00128 CHECK_CONVERTIBILITY(typename instigate::stl::readable_iterator::
00129 interface<I>::value_type,
00130 typename instigate::stl::unary_predicate::
00131 interface<P>::argument_type);
00132 CHECK_CONVERTIBILITY(T, typename instigate::stl::writable_iterator::
00133 interface<O>::value_type);
00134 CHECK_CONVERTIBILITY(typename instigate::stl::readable_iterator::
00135 interface<I>::value_type,
00136 typename instigate::stl::writable_iterator::
00137 interface<O>::value_type);
00138 for ( ; !equal(f, l); increment(f), increment(r)) {
00139 dereference_assign(r,
00140 invoke_predicate(p, const_dereference(f)) ?
00141 n : const_dereference(f));
00142 }
00143 return r;
00144 }
00145
00146
00147
00148 #endif // INSTIGATE_STL_REPLACE_COPY_IF_HPP