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