| 
									
										
										
										
											2013-05-09 17:22:46 +00:00
										 |  |  | /* 
 | 
					
						
							|  |  |  |    Copyright (c) Marshall Clow 2008-2012. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |    Distributed under the Boost Software License, Version 1.0. (See accompanying | 
					
						
							| 
									
										
										
										
											2018-07-30 13:07:36 -07:00
										 |  |  |    file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
 | 
					
						
							| 
									
										
										
										
											2013-05-09 17:22:46 +00:00
										 |  |  | */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /// \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
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-10-14 21:31:19 +00:00
										 |  |  | #include <utility>      // for std::pair
 | 
					
						
							| 
									
										
										
										
											2019-12-03 08:33:05 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-01-25 13:11:01 +03:00
										 |  |  | #include <boost/config.hpp>
 | 
					
						
							| 
									
										
										
										
											2013-05-09 17:22:46 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | namespace boost { namespace algorithm { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /// \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
 | 
					
						
							| 
									
										
										
										
											2013-05-23 18:29:49 +00:00
										 |  |  | template <class InputIterator1, class InputIterator2, class BinaryPredicate> | 
					
						
							| 
									
										
										
										
											2016-01-25 13:11:01 +03:00
										 |  |  | BOOST_CXX14_CONSTEXPR std::pair<InputIterator1, InputIterator2> mismatch ( | 
					
						
							| 
									
										
										
										
											2013-10-14 21:31:19 +00:00
										 |  |  |                     InputIterator1 first1, InputIterator1 last1, | 
					
						
							|  |  |  |                     InputIterator2 first2, InputIterator2 last2, | 
					
						
							|  |  |  |                     BinaryPredicate pred ) | 
					
						
							| 
									
										
										
										
											2013-05-09 17:22:46 +00:00
										 |  |  | { | 
					
						
							|  |  |  |     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> | 
					
						
							| 
									
										
										
										
											2016-01-25 13:11:01 +03:00
										 |  |  | BOOST_CXX14_CONSTEXPR std::pair<InputIterator1, InputIterator2> mismatch ( | 
					
						
							| 
									
										
										
										
											2013-10-14 21:31:19 +00:00
										 |  |  |                     InputIterator1 first1, InputIterator1 last1, | 
					
						
							|  |  |  |                     InputIterator2 first2, InputIterator2 last2 ) | 
					
						
							| 
									
										
										
										
											2013-05-09 17:22:46 +00:00
										 |  |  | { | 
					
						
							|  |  |  |     for (; first1 != last1 && first2 != last2; ++first1, ++first2) | 
					
						
							|  |  |  |         if ( *first1 != *first2 ) | 
					
						
							|  |  |  |             break; | 
					
						
							|  |  |  |     return std::pair<InputIterator1, InputIterator2>(first1, first2); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-10-14 21:31:19 +00:00
										 |  |  | //  There are already range-based versions of these.
 | 
					
						
							| 
									
										
										
										
											2013-05-09 17:22:46 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | }} // namespace boost and algorithm
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #endif // BOOST_ALGORITHM_MISMATCH_HPP
 |