221
|
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 <__config>
|
|
14 #include <__iterator/iterator_traits.h>
|
|
15 #include <utility>
|
|
16
|
|
17 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
|
18 #pragma GCC system_header
|
|
19 #endif
|
|
20
|
|
21 _LIBCPP_PUSH_MACROS
|
|
22 #include <__undef_macros>
|
|
23
|
|
24 _LIBCPP_BEGIN_NAMESPACE_STD
|
|
25
|
|
26 template <class _InputIterator1, class _InputIterator2, class _BinaryPredicate>
|
|
27 _LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY
|
|
28 _LIBCPP_CONSTEXPR_AFTER_CXX17 pair<_InputIterator1, _InputIterator2>
|
|
29 mismatch(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _BinaryPredicate __pred) {
|
|
30 for (; __first1 != __last1; ++__first1, (void)++__first2)
|
|
31 if (!__pred(*__first1, *__first2))
|
|
32 break;
|
|
33 return pair<_InputIterator1, _InputIterator2>(__first1, __first2);
|
|
34 }
|
|
35
|
|
36 template <class _InputIterator1, class _InputIterator2>
|
|
37 _LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY
|
|
38 _LIBCPP_CONSTEXPR_AFTER_CXX17 pair<_InputIterator1, _InputIterator2>
|
|
39 mismatch(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2) {
|
|
40 typedef typename iterator_traits<_InputIterator1>::value_type __v1;
|
|
41 typedef typename iterator_traits<_InputIterator2>::value_type __v2;
|
|
42 return _VSTD::mismatch(__first1, __last1, __first2, __equal_to<__v1, __v2>());
|
|
43 }
|
|
44
|
|
45 #if _LIBCPP_STD_VER > 11
|
|
46 template <class _InputIterator1, class _InputIterator2, class _BinaryPredicate>
|
|
47 _LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY
|
|
48 _LIBCPP_CONSTEXPR_AFTER_CXX17 pair<_InputIterator1, _InputIterator2>
|
|
49 mismatch(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2,
|
|
50 _BinaryPredicate __pred) {
|
|
51 for (; __first1 != __last1 && __first2 != __last2; ++__first1, (void)++__first2)
|
|
52 if (!__pred(*__first1, *__first2))
|
|
53 break;
|
|
54 return pair<_InputIterator1, _InputIterator2>(__first1, __first2);
|
|
55 }
|
|
56
|
|
57 template <class _InputIterator1, class _InputIterator2>
|
|
58 _LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY
|
|
59 _LIBCPP_CONSTEXPR_AFTER_CXX17 pair<_InputIterator1, _InputIterator2>
|
|
60 mismatch(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2) {
|
|
61 typedef typename iterator_traits<_InputIterator1>::value_type __v1;
|
|
62 typedef typename iterator_traits<_InputIterator2>::value_type __v2;
|
|
63 return _VSTD::mismatch(__first1, __last1, __first2, __last2, __equal_to<__v1, __v2>());
|
|
64 }
|
|
65 #endif
|
|
66
|
|
67 _LIBCPP_END_NAMESPACE_STD
|
|
68
|
|
69 _LIBCPP_POP_MACROS
|
|
70
|
|
71 #endif // _LIBCPP___ALGORITHM_MISMATCH_H
|