File indexing completed on 2026-05-03 08:13:20
0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef _LIBCPP___CXX03___ALGORITHM_RANGES_IS_PERMUTATION_H
0010 #define _LIBCPP___CXX03___ALGORITHM_RANGES_IS_PERMUTATION_H
0011
0012 #include <__cxx03/__algorithm/is_permutation.h>
0013 #include <__cxx03/__algorithm/iterator_operations.h>
0014 #include <__cxx03/__config>
0015 #include <__cxx03/__functional/identity.h>
0016 #include <__cxx03/__functional/ranges_operations.h>
0017 #include <__cxx03/__iterator/concepts.h>
0018 #include <__cxx03/__iterator/distance.h>
0019 #include <__cxx03/__iterator/projected.h>
0020 #include <__cxx03/__ranges/access.h>
0021 #include <__cxx03/__ranges/concepts.h>
0022 #include <__cxx03/__utility/move.h>
0023
0024 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
0025 # pragma GCC system_header
0026 #endif
0027
0028 _LIBCPP_PUSH_MACROS
0029 #include <__cxx03/__undef_macros>
0030
0031 #if _LIBCPP_STD_VER >= 20
0032
0033 _LIBCPP_BEGIN_NAMESPACE_STD
0034
0035 namespace ranges {
0036 namespace __is_permutation {
0037 struct __fn {
0038 template <class _Iter1, class _Sent1, class _Iter2, class _Sent2, class _Proj1, class _Proj2, class _Pred>
0039 _LIBCPP_HIDE_FROM_ABI constexpr static bool __is_permutation_func_impl(
0040 _Iter1 __first1,
0041 _Sent1 __last1,
0042 _Iter2 __first2,
0043 _Sent2 __last2,
0044 _Pred& __pred,
0045 _Proj1& __proj1,
0046 _Proj2& __proj2) {
0047 return std::__is_permutation<_RangeAlgPolicy>(
0048 std::move(__first1), std::move(__last1), std::move(__first2), std::move(__last2), __pred, __proj1, __proj2);
0049 }
0050
0051 template <
0052 forward_iterator _Iter1,
0053 sentinel_for<_Iter1> _Sent1,
0054 forward_iterator _Iter2,
0055 sentinel_for<_Iter2> _Sent2,
0056 class _Proj1 = identity,
0057 class _Proj2 = identity,
0058 indirect_equivalence_relation<projected<_Iter1, _Proj1>, projected<_Iter2, _Proj2>> _Pred = ranges::equal_to>
0059 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool operator()(
0060 _Iter1 __first1,
0061 _Sent1 __last1,
0062 _Iter2 __first2,
0063 _Sent2 __last2,
0064 _Pred __pred = {},
0065 _Proj1 __proj1 = {},
0066 _Proj2 __proj2 = {}) const {
0067 return __is_permutation_func_impl(
0068 std::move(__first1), std::move(__last1), std::move(__first2), std::move(__last2), __pred, __proj1, __proj2);
0069 }
0070
0071 template <forward_range _Range1,
0072 forward_range _Range2,
0073 class _Proj1 = identity,
0074 class _Proj2 = identity,
0075 indirect_equivalence_relation<projected<iterator_t<_Range1>, _Proj1>,
0076 projected<iterator_t<_Range2>, _Proj2>> _Pred = ranges::equal_to>
0077 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool operator()(
0078 _Range1&& __range1, _Range2&& __range2, _Pred __pred = {}, _Proj1 __proj1 = {}, _Proj2 __proj2 = {}) const {
0079 if constexpr (sized_range<_Range1> && sized_range<_Range2>) {
0080 if (ranges::distance(__range1) != ranges::distance(__range2))
0081 return false;
0082 }
0083
0084 return __is_permutation_func_impl(
0085 ranges::begin(__range1),
0086 ranges::end(__range1),
0087 ranges::begin(__range2),
0088 ranges::end(__range2),
0089 __pred,
0090 __proj1,
0091 __proj2);
0092 }
0093 };
0094 }
0095
0096 inline namespace __cpo {
0097 inline constexpr auto is_permutation = __is_permutation::__fn{};
0098 }
0099 }
0100
0101 _LIBCPP_END_NAMESPACE_STD
0102
0103 #endif
0104
0105 _LIBCPP_POP_MACROS
0106
0107 #endif