1 // -*- C++ -*- 2 //===----------------------------------------------------------------------===// 3 // 4 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 5 // See https://llvm.org/LICENSE.txt for license information. 6 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 7 // 8 //===----------------------------------------------------------------------===// 9 10 #ifndef _LIBCPP___ALGORITHM_MISMATCH_H 11 #define _LIBCPP___ALGORITHM_MISMATCH_H 12 13 #include <__algorithm/comp.h> 14 #include <__config> 15 #include <__iterator/iterator_traits.h> 16 #include <__utility/pair.h> 17 18 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 19 # pragma GCC system_header 20 #endif 21 22 _LIBCPP_BEGIN_NAMESPACE_STD 23 24 template <class _InputIterator1, class _InputIterator2, class _BinaryPredicate> 25 _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_InputIterator1, _InputIterator2> 26 mismatch(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _BinaryPredicate __pred) { 27 for (; __first1 != __last1; ++__first1, (void)++__first2) 28 if (!__pred(*__first1, *__first2)) 29 break; 30 return pair<_InputIterator1, _InputIterator2>(__first1, __first2); 31 } 32 33 template <class _InputIterator1, class _InputIterator2> 34 _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_InputIterator1, _InputIterator2> 35 mismatch(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2) { 36 return std::mismatch(__first1, __last1, __first2, __equal_to()); 37 } 38 39 #if _LIBCPP_STD_VER >= 14 40 template <class _InputIterator1, class _InputIterator2, class _BinaryPredicate> 41 _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_InputIterator1, _InputIterator2> 42 mismatch(_InputIterator1 __first1, 43 _InputIterator1 __last1, 44 _InputIterator2 __first2, 45 _InputIterator2 __last2, 46 _BinaryPredicate __pred) { 47 for (; __first1 != __last1 && __first2 != __last2; ++__first1, (void)++__first2) 48 if (!__pred(*__first1, *__first2)) 49 break; 50 return pair<_InputIterator1, _InputIterator2>(__first1, __first2); 51 } 52 53 template <class _InputIterator1, class _InputIterator2> 54 _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_InputIterator1, _InputIterator2> 55 mismatch(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2) { 56 return std::mismatch(__first1, __last1, __first2, __last2, __equal_to()); 57 } 58 #endif 59 60 _LIBCPP_END_NAMESPACE_STD 61 62 #endif // _LIBCPP___ALGORITHM_MISMATCH_H 63