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_MISMATCH_HPP
00008 #define INSTIGATE_STL_MISMATCH_HPP
00009
00058
00059 #include "concept.hpp"
00060
00061
00062
00063
00064
00065
00066 namespace instigate {
00067 namespace stl {
00068 template <typename I, typename I2, typename P>
00069 inline void mismatch(I b, I e, I2 f, P& r);
00070 template <typename I, typename I2, typename B,
00071 typename P>
00072 inline void mismatch(I b, I e, I2 f,B p, P& r);
00073 }
00074 }
00075
00110 template <typename I, typename I2, typename P>
00111 inline void instigate::stl::mismatch(I b, I e, I2 f, P& r)
00112 {
00113 namespace SP = instigate::stl::single_pass_iterator;
00114 namespace RI = instigate::stl::readable_iterator;
00115 namespace PR = instigate::stl::pair;
00116 namespace EQ = instigate::generic::equality_comparable;
00117 typedef typename RI::interface<I>::value_type value_type1;
00118 typedef typename RI::interface<I>::value_type value_type2;
00119 CHECK(SP::requirements<I>);
00120 CHECK(RI::requirements<I>);
00121 CHECK(SP::requirements<I2>);
00122 CHECK(RI::requirements<I2>);
00123 CHECK(PR::requirements<P>);
00124 CHECK(EQ::requirements<value_type1>);
00125 CHECK(EQ::requirements<value_type2>);
00126 while (!equal(b, e) && equal(const_dereference(b),
00127 const_dereference(f))) {
00128 increment(b);
00129 increment(f);
00130 }
00131 assign(r.first, b);
00132 assign(r.second, f);
00133 }
00134
00167 template <typename I, typename I2, typename B, typename P>
00168 inline void instigate::stl::mismatch(I b, I e, I2 f, B p, P& r)
00169 {
00170 namespace SP = instigate::stl::single_pass_iterator;
00171 namespace RI = instigate::stl::readable_iterator;
00172 namespace PR = instigate::stl::pair;
00173 namespace EQ = instigate::generic::equality_comparable;
00174 namespace BP = instigate::stl::binary_predicate;
00175 typedef typename RI::interface<I>::value_type value_type1;
00176 typedef typename RI::interface<I>::value_type value_type2;
00177 typedef typename BP::interface<B>::first_argument_type
00178 first_argument_type;
00179 typedef typename BP::interface<B>::second_argument_type
00180 second_argument_type;
00181 typedef typename BP::interface<B>::result_type result_type;
00182 CHECK_CONVERTIBILITY(value_type1, first_argument_type);
00183 CHECK_CONVERTIBILITY(value_type2, second_argument_type);
00184 CHECK_CONVERTIBILITY(result_type, bool);
00185 CHECK(SP::requirements<I>);
00186 CHECK(RI::requirements<I>);
00187 CHECK(SP::requirements<I2>);
00188 CHECK(RI::requirements<I2>);
00189 CHECK(PR::requirements<P>);
00190 CHECK(BP::requirements<B>);
00191 while (!equal(b, e) &&
00192 invoke_predicate(p, const_dereference(b),
00193 const_dereference(f)))
00194 {
00195 increment(b);
00196 increment(f);
00197 }
00198 assign(r.first, b);
00199 assign(r.second, f);
00200 }
00201
00202
00203
00204 #endif // INSTIGATE_STL_MISMATCH_HPP