]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/algorithm/include/boost/algorithm/cxx14/mismatch.hpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / algorithm / include / boost / algorithm / cxx14 / mismatch.hpp
1 /*
2 Copyright (c) Marshall Clow 2008-2012.
3
4 Distributed under the Boost Software License, Version 1.0. (See accompanying
5 file LICENSE10.txt or copy at http://www.boost.org/LICENSE10.txt)
6 */
7
8 /// \file mismatch.hpp
9 /// \brief Find the first mismatched element in a sequence
10 /// \author Marshall Clow
11
12 #ifndef BOOST_ALGORITHM_MISMATCH_HPP
13 #define BOOST_ALGORITHM_MISMATCH_HPP
14
15 #include <utility> // for std::pair
16
17 namespace boost { namespace algorithm {
18
19 /// \fn mismatch ( InputIterator1 first1, InputIterator1 last1,
20 /// InputIterator2 first2, InputIterator2 last2,
21 /// BinaryPredicate pred )
22 /// \return a pair of iterators pointing to the first elements in the sequence that do not match
23 ///
24 /// \param first1 The start of the first range.
25 /// \param last1 One past the end of the first range.
26 /// \param first2 The start of the second range.
27 /// \param last2 One past the end of the second range.
28 /// \param pred A predicate for comparing the elements of the ranges
29 template <class InputIterator1, class InputIterator2, class BinaryPredicate>
30 std::pair<InputIterator1, InputIterator2> mismatch (
31 InputIterator1 first1, InputIterator1 last1,
32 InputIterator2 first2, InputIterator2 last2,
33 BinaryPredicate pred )
34 {
35 for (; first1 != last1 && first2 != last2; ++first1, ++first2)
36 if ( !pred ( *first1, *first2 ))
37 break;
38 return std::pair<InputIterator1, InputIterator2>(first1, first2);
39 }
40
41 /// \fn mismatch ( InputIterator1 first1, InputIterator1 last1,
42 /// InputIterator2 first2, InputIterator2 last2 )
43 /// \return a pair of iterators pointing to the first elements in the sequence that do not match
44 ///
45 /// \param first1 The start of the first range.
46 /// \param last1 One past the end of the first range.
47 /// \param first2 The start of the second range.
48 /// \param last2 One past the end of the second range.
49 template <class InputIterator1, class InputIterator2>
50 std::pair<InputIterator1, InputIterator2> mismatch (
51 InputIterator1 first1, InputIterator1 last1,
52 InputIterator2 first2, InputIterator2 last2 )
53 {
54 for (; first1 != last1 && first2 != last2; ++first1, ++first2)
55 if ( *first1 != *first2 )
56 break;
57 return std::pair<InputIterator1, InputIterator2>(first1, first2);
58 }
59
60 // There are already range-based versions of these.
61
62 }} // namespace boost and algorithm
63
64 #endif // BOOST_ALGORITHM_MISMATCH_HPP