Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / libcxx / include / __algorithm / mismatch.h
blobe5b014f45738a1d12e325c1c3afc06a639c4ad44
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 //===----------------------------------------------------------------------===//
10 #ifndef _LIBCPP___ALGORITHM_MISMATCH_H
11 #define _LIBCPP___ALGORITHM_MISMATCH_H
13 #include <__algorithm/comp.h>
14 #include <__config>
15 #include <__iterator/iterator_traits.h>
16 #include <__utility/pair.h>
18 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
19 # pragma GCC system_header
20 #endif
22 _LIBCPP_BEGIN_NAMESPACE_STD
24 template <class _InputIterator1, class _InputIterator2, class _BinaryPredicate>
25 _LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY
26 _LIBCPP_CONSTEXPR_SINCE_CXX20 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);
34 template <class _InputIterator1, class _InputIterator2>
35 _LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY
36 _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_InputIterator1, _InputIterator2>
37 mismatch(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2) {
38 return std::mismatch(__first1, __last1, __first2, __equal_to());
41 #if _LIBCPP_STD_VER >= 14
42 template <class _InputIterator1, class _InputIterator2, class _BinaryPredicate>
43 _LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY
44 _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_InputIterator1, _InputIterator2>
45 mismatch(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _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);
53 template <class _InputIterator1, class _InputIterator2>
54 _LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY
55 _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_InputIterator1, _InputIterator2>
56 mismatch(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2) {
57 return std::mismatch(__first1, __last1, __first2, __last2, __equal_to());
59 #endif
61 _LIBCPP_END_NAMESPACE_STD
63 #endif // _LIBCPP___ALGORITHM_MISMATCH_H