Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:28:23

0001 /* 
0002    Copyright (c) Marshall Clow 2008-2012.
0003 
0004    Distributed under the Boost Software License, Version 1.0. (See accompanying
0005    file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0006 */
0007 
0008 /// \file  mismatch.hpp
0009 /// \brief Find the first mismatched element in a sequence
0010 /// \author Marshall Clow
0011 
0012 #ifndef BOOST_ALGORITHM_MISMATCH_HPP
0013 #define BOOST_ALGORITHM_MISMATCH_HPP
0014 
0015 #include <utility>      // for std::pair
0016 
0017 #include <boost/config.hpp>
0018 
0019 namespace boost { namespace algorithm {
0020 
0021 /// \fn mismatch ( InputIterator1 first1, InputIterator1 last1, 
0022 ///                InputIterator2 first2, InputIterator2 last2,
0023 ///                BinaryPredicate pred )
0024 /// \return a pair of iterators pointing to the first elements in the sequence that do not match
0025 /// 
0026 /// \param first1    The start of the first range.
0027 /// \param last1     One past the end of the first range.
0028 /// \param first2    The start of the second range.
0029 /// \param last2     One past the end of the second range.
0030 /// \param pred      A predicate for comparing the elements of the ranges
0031 template <class InputIterator1, class InputIterator2, class BinaryPredicate>
0032 BOOST_CXX14_CONSTEXPR std::pair<InputIterator1, InputIterator2> mismatch (
0033                     InputIterator1 first1, InputIterator1 last1,
0034                     InputIterator2 first2, InputIterator2 last2,
0035                     BinaryPredicate pred )
0036 {
0037     for (; first1 != last1 && first2 != last2; ++first1, ++first2)
0038         if ( !pred ( *first1, *first2 ))
0039             break;
0040     return std::pair<InputIterator1, InputIterator2>(first1, first2);
0041 }
0042 
0043 /// \fn mismatch ( InputIterator1 first1, InputIterator1 last1, 
0044 ///                InputIterator2 first2, InputIterator2 last2 )
0045 /// \return a pair of iterators pointing to the first elements in the sequence that do not match
0046 /// 
0047 /// \param first1    The start of the first range.
0048 /// \param last1     One past the end of the first range.
0049 /// \param first2    The start of the second range.
0050 /// \param last2     One past the end of the second range.
0051 template <class InputIterator1, class InputIterator2>
0052 BOOST_CXX14_CONSTEXPR std::pair<InputIterator1, InputIterator2> mismatch (
0053                     InputIterator1 first1, InputIterator1 last1,
0054                     InputIterator2 first2, InputIterator2 last2 )
0055 {
0056     for (; first1 != last1 && first2 != last2; ++first1, ++first2)
0057         if ( *first1 != *first2 )
0058             break;
0059     return std::pair<InputIterator1, InputIterator2>(first1, first2);
0060 }
0061 
0062 //  There are already range-based versions of these.
0063 
0064 }} // namespace boost and algorithm
0065 
0066 #endif // BOOST_ALGORITHM_MISMATCH_HPP