summaryrefslogtreecommitdiff
path: root/boost/algorithm/cxx14/mismatch.hpp
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@baserock.org>2013-06-25 22:59:01 +0000
committer <>2013-09-27 11:49:28 +0000
commit8c4528713d907ee2cfd3bfcbbad272c749867f84 (patch)
treec09e2ce80f47b90c85cc720f5139089ad9c8cfff /boost/algorithm/cxx14/mismatch.hpp
downloadboost-tarball-baserock/morph.tar.gz
Imported from /home/lorry/working-area/delta_boost-tarball/boost_1_54_0.tar.bz2.boost_1_54_0baserock/morph
Diffstat (limited to 'boost/algorithm/cxx14/mismatch.hpp')
-rw-r--r--boost/algorithm/cxx14/mismatch.hpp66
1 files changed, 66 insertions, 0 deletions
diff --git a/boost/algorithm/cxx14/mismatch.hpp b/boost/algorithm/cxx14/mismatch.hpp
new file mode 100644
index 000000000..5229e3bda
--- /dev/null
+++ b/boost/algorithm/cxx14/mismatch.hpp
@@ -0,0 +1,66 @@
+/*
+ Copyright (c) Marshall Clow 2008-2012.
+
+ Distributed under the Boost Software License, Version 1.0. (See accompanying
+ file LICENSE10.txt or copy at http://www.boost.org/LICENSE10.txt)
+*/
+
+/// \file mismatch.hpp
+/// \brief Find the first mismatched element in a sequence
+/// \author Marshall Clow
+
+#ifndef BOOST_ALGORITHM_MISMATCH_HPP
+#define BOOST_ALGORITHM_MISMATCH_HPP
+
+#include <algorithm> // for std::mismatch
+#include <utility> // for std::pair
+
+namespace boost { namespace algorithm {
+
+template <class InputIterator1, class InputIterator2, class BinaryPredicate>
+
+/// \fn mismatch ( InputIterator1 first1, InputIterator1 last1,
+/// InputIterator2 first2, InputIterator2 last2,
+/// BinaryPredicate pred )
+/// \return a pair of iterators pointing to the first elements in the sequence that do not match
+///
+/// \param first1 The start of the first range.
+/// \param last1 One past the end of the first range.
+/// \param first2 The start of the second range.
+/// \param last2 One past the end of the second range.
+/// \param pred A predicate for comparing the elements of the ranges
+std::pair<InputIterator1, InputIterator2> mismatch (
+ InputIterator1 first1, InputIterator1 last1,
+ InputIterator2 first2, InputIterator2 last2,
+ BinaryPredicate pred )
+{
+ for (; first1 != last1 && first2 != last2; ++first1, ++first2)
+ if ( !pred ( *first1, *first2 ))
+ break;
+ return std::pair<InputIterator1, InputIterator2>(first1, first2);
+}
+
+/// \fn mismatch ( InputIterator1 first1, InputIterator1 last1,
+/// InputIterator2 first2, InputIterator2 last2 )
+/// \return a pair of iterators pointing to the first elements in the sequence that do not match
+///
+/// \param first1 The start of the first range.
+/// \param last1 One past the end of the first range.
+/// \param first2 The start of the second range.
+/// \param last2 One past the end of the second range.
+template <class InputIterator1, class InputIterator2>
+std::pair<InputIterator1, InputIterator2> mismatch (
+ InputIterator1 first1, InputIterator1 last1,
+ InputIterator2 first2, InputIterator2 last2 )
+{
+ for (; first1 != last1 && first2 != last2; ++first1, ++first2)
+ if ( *first1 != *first2 )
+ break;
+ return std::pair<InputIterator1, InputIterator2>(first1, first2);
+}
+
+// There are already range-based versions of these.
+
+}} // namespace boost and algorithm
+
+#endif // BOOST_ALGORITHM_MISMATCH_HPP