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_INLINE_VISIBILITY
26     _LIBCPP_CONSTEXPR_AFTER_CXX17 pair<_InputIterator1, _InputIterator2>
27     mismatch(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _BinaryPredicate __pred) {
28   for (; __first1 != __last1; ++__first1, (void)++__first2)
29     if (!__pred(*__first1, *__first2))
30       break;
31   return pair<_InputIterator1, _InputIterator2>(__first1, __first2);
32 }
33 
34 template <class _InputIterator1, class _InputIterator2>
35 _LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY
36     _LIBCPP_CONSTEXPR_AFTER_CXX17 pair<_InputIterator1, _InputIterator2>
37     mismatch(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2) {
38   typedef typename iterator_traits<_InputIterator1>::value_type __v1;
39   typedef typename iterator_traits<_InputIterator2>::value_type __v2;
40   return _VSTD::mismatch(__first1, __last1, __first2, __equal_to<__v1, __v2>());
41 }
42 
43 #if _LIBCPP_STD_VER > 11
44 template <class _InputIterator1, class _InputIterator2, class _BinaryPredicate>
45 _LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY
46     _LIBCPP_CONSTEXPR_AFTER_CXX17 pair<_InputIterator1, _InputIterator2>
47     mismatch(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2,
48              _BinaryPredicate __pred) {
49   for (; __first1 != __last1 && __first2 != __last2; ++__first1, (void)++__first2)
50     if (!__pred(*__first1, *__first2))
51       break;
52   return pair<_InputIterator1, _InputIterator2>(__first1, __first2);
53 }
54 
55 template <class _InputIterator1, class _InputIterator2>
56 _LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY
57     _LIBCPP_CONSTEXPR_AFTER_CXX17 pair<_InputIterator1, _InputIterator2>
58     mismatch(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2) {
59   typedef typename iterator_traits<_InputIterator1>::value_type __v1;
60   typedef typename iterator_traits<_InputIterator2>::value_type __v2;
61   return _VSTD::mismatch(__first1, __last1, __first2, __last2, __equal_to<__v1, __v2>());
62 }
63 #endif
64 
65 _LIBCPP_END_NAMESPACE_STD
66 
67 #endif // _LIBCPP___ALGORITHM_MISMATCH_H
68