Warning: This file is not a C or C++ file. It does not have highlighting.
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___CXX03___ALGORITHM_EQUAL_H |
11 | #define _LIBCPP___CXX03___ALGORITHM_EQUAL_H |
12 | |
13 | #include <__cxx03/__algorithm/comp.h> |
14 | #include <__cxx03/__algorithm/unwrap_iter.h> |
15 | #include <__cxx03/__config> |
16 | #include <__cxx03/__functional/identity.h> |
17 | #include <__cxx03/__iterator/distance.h> |
18 | #include <__cxx03/__iterator/iterator_traits.h> |
19 | #include <__cxx03/__string/constexpr_c_functions.h> |
20 | #include <__cxx03/__type_traits/desugars_to.h> |
21 | #include <__cxx03/__type_traits/enable_if.h> |
22 | #include <__cxx03/__type_traits/invoke.h> |
23 | #include <__cxx03/__type_traits/is_equality_comparable.h> |
24 | #include <__cxx03/__type_traits/is_volatile.h> |
25 | #include <__cxx03/__utility/move.h> |
26 | |
27 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
28 | # pragma GCC system_header |
29 | #endif |
30 | |
31 | _LIBCPP_PUSH_MACROS |
32 | #include <__cxx03/__undef_macros> |
33 | |
34 | _LIBCPP_BEGIN_NAMESPACE_STD |
35 | |
36 | template <class _InputIterator1, class _InputIterator2, class _BinaryPredicate> |
37 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI bool __equal_iter_impl( |
38 | _InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _BinaryPredicate& __pred) { |
39 | for (; __first1 != __last1; ++__first1, (void)++__first2) |
40 | if (!__pred(*__first1, *__first2)) |
41 | return false; |
42 | return true; |
43 | } |
44 | |
45 | template <class _Tp, |
46 | class _Up, |
47 | class _BinaryPredicate, |
48 | __enable_if_t<__desugars_to_v<__equal_tag, _BinaryPredicate, _Tp, _Up> && !is_volatile<_Tp>::value && |
49 | !is_volatile<_Up>::value && __libcpp_is_trivially_equality_comparable<_Tp, _Up>::value, |
50 | int> = 0> |
51 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI bool |
52 | __equal_iter_impl(_Tp* __first1, _Tp* __last1, _Up* __first2, _BinaryPredicate&) { |
53 | return std::__constexpr_memcmp_equal(__first1, __first2, __element_count(__last1 - __first1)); |
54 | } |
55 | |
56 | template <class _InputIterator1, class _InputIterator2, class _BinaryPredicate> |
57 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI bool |
58 | equal(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _BinaryPredicate __pred) { |
59 | return std::__equal_iter_impl( |
60 | std::__unwrap_iter(__first1), std::__unwrap_iter(__last1), std::__unwrap_iter(__first2), __pred); |
61 | } |
62 | |
63 | template <class _InputIterator1, class _InputIterator2> |
64 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI bool |
65 | equal(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2) { |
66 | return std::equal(__first1, __last1, __first2, __equal_to()); |
67 | } |
68 | |
69 | _LIBCPP_END_NAMESPACE_STD |
70 | |
71 | _LIBCPP_POP_MACROS |
72 | |
73 | #endif // _LIBCPP___CXX03___ALGORITHM_EQUAL_H |
74 |
Warning: This file is not a C or C++ file. It does not have highlighting.