Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-03 08:13:20

0001 //===----------------------------------------------------------------------===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 
0009 #ifndef _LIBCPP___CXX03___ALGORITHM_RANGES_MISMATCH_H
0010 #define _LIBCPP___CXX03___ALGORITHM_RANGES_MISMATCH_H
0011 
0012 #include <__cxx03/__algorithm/in_in_result.h>
0013 #include <__cxx03/__algorithm/mismatch.h>
0014 #include <__cxx03/__algorithm/unwrap_range.h>
0015 #include <__cxx03/__config>
0016 #include <__cxx03/__functional/identity.h>
0017 #include <__cxx03/__functional/invoke.h>
0018 #include <__cxx03/__functional/ranges_operations.h>
0019 #include <__cxx03/__iterator/concepts.h>
0020 #include <__cxx03/__iterator/indirectly_comparable.h>
0021 #include <__cxx03/__ranges/access.h>
0022 #include <__cxx03/__ranges/concepts.h>
0023 #include <__cxx03/__ranges/dangling.h>
0024 #include <__cxx03/__utility/move.h>
0025 
0026 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
0027 #  pragma GCC system_header
0028 #endif
0029 
0030 _LIBCPP_PUSH_MACROS
0031 #include <__cxx03/__undef_macros>
0032 
0033 _LIBCPP_BEGIN_NAMESPACE_STD
0034 
0035 #if _LIBCPP_STD_VER >= 20
0036 
0037 namespace ranges {
0038 
0039 template <class _I1, class _I2>
0040 using mismatch_result = in_in_result<_I1, _I2>;
0041 
0042 namespace __mismatch {
0043 struct __fn {
0044   template <class _I1, class _S1, class _I2, class _S2, class _Pred, class _Proj1, class _Proj2>
0045   static _LIBCPP_HIDE_FROM_ABI constexpr mismatch_result<_I1, _I2>
0046   __go(_I1 __first1, _S1 __last1, _I2 __first2, _S2 __last2, _Pred& __pred, _Proj1& __proj1, _Proj2& __proj2) {
0047     if constexpr (forward_iterator<_I1> && forward_iterator<_I2>) {
0048       auto __range1 = std::__unwrap_range(__first1, __last1);
0049       auto __range2 = std::__unwrap_range(__first2, __last2);
0050       auto __res =
0051           std::__mismatch(__range1.first, __range1.second, __range2.first, __range2.second, __pred, __proj1, __proj2);
0052       return {std::__rewrap_range<_S1>(__first1, __res.first), std::__rewrap_range<_S2>(__first2, __res.second)};
0053     } else {
0054       auto __res = std::__mismatch(
0055           std::move(__first1), std::move(__last1), std::move(__first2), std::move(__last2), __pred, __proj1, __proj2);
0056       return {std::move(__res.first), std::move(__res.second)};
0057     }
0058   }
0059 
0060   template <input_iterator _I1,
0061             sentinel_for<_I1> _S1,
0062             input_iterator _I2,
0063             sentinel_for<_I2> _S2,
0064             class _Pred  = ranges::equal_to,
0065             class _Proj1 = identity,
0066             class _Proj2 = identity>
0067     requires indirectly_comparable<_I1, _I2, _Pred, _Proj1, _Proj2>
0068   [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr mismatch_result<_I1, _I2> operator()(
0069       _I1 __first1, _S1 __last1, _I2 __first2, _S2 __last2, _Pred __pred = {}, _Proj1 __proj1 = {}, _Proj2 __proj2 = {})
0070       const {
0071     return __go(std::move(__first1), __last1, std::move(__first2), __last2, __pred, __proj1, __proj2);
0072   }
0073 
0074   template <input_range _R1,
0075             input_range _R2,
0076             class _Pred  = ranges::equal_to,
0077             class _Proj1 = identity,
0078             class _Proj2 = identity>
0079     requires indirectly_comparable<iterator_t<_R1>, iterator_t<_R2>, _Pred, _Proj1, _Proj2>
0080   [[nodiscard]]
0081   _LIBCPP_HIDE_FROM_ABI constexpr mismatch_result<borrowed_iterator_t<_R1>, borrowed_iterator_t<_R2>>
0082   operator()(_R1&& __r1, _R2&& __r2, _Pred __pred = {}, _Proj1 __proj1 = {}, _Proj2 __proj2 = {}) const {
0083     return __go(
0084         ranges::begin(__r1), ranges::end(__r1), ranges::begin(__r2), ranges::end(__r2), __pred, __proj1, __proj2);
0085   }
0086 };
0087 } // namespace __mismatch
0088 
0089 inline namespace __cpo {
0090 constexpr inline auto mismatch = __mismatch::__fn{};
0091 } // namespace __cpo
0092 } // namespace ranges
0093 
0094 #endif // _LIBCPP_STD_VER >= 20
0095 
0096 _LIBCPP_END_NAMESPACE_STD
0097 
0098 _LIBCPP_POP_MACROS
0099 
0100 #endif // _LIBCPP___CXX03___ALGORITHM_RANGES_MISMATCH_H