xref: /llvm-project/libcxx/include/__algorithm/ranges_includes.h (revision d10dc5a06fac4dcabf2264c64c8672c6f6ae36fb)
1 //===----------------------------------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #ifndef _LIBCPP___ALGORITHM_RANGES_INCLUDES_H
10 #define _LIBCPP___ALGORITHM_RANGES_INCLUDES_H
11 
12 #include <__algorithm/includes.h>
13 #include <__algorithm/make_projected.h>
14 #include <__config>
15 #include <__functional/identity.h>
16 #include <__functional/invoke.h>
17 #include <__functional/ranges_operations.h>
18 #include <__iterator/concepts.h>
19 #include <__iterator/iterator_traits.h>
20 #include <__iterator/projected.h>
21 #include <__ranges/access.h>
22 #include <__ranges/concepts.h>
23 #include <__utility/forward.h>
24 #include <__utility/move.h>
25 
26 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
27 #  pragma GCC system_header
28 #endif
29 
30 _LIBCPP_PUSH_MACROS
31 #include <__undef_macros>
32 
33 #if _LIBCPP_STD_VER >= 20
34 
35 _LIBCPP_BEGIN_NAMESPACE_STD
36 
37 namespace ranges {
38 struct __includes {
39   template <input_iterator _Iter1,
40             sentinel_for<_Iter1> _Sent1,
41             input_iterator _Iter2,
42             sentinel_for<_Iter2> _Sent2,
43             class _Proj1                                                                           = identity,
44             class _Proj2                                                                           = identity,
45             indirect_strict_weak_order<projected<_Iter1, _Proj1>, projected<_Iter2, _Proj2>> _Comp = ranges::less>
46   [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool operator()(
47       _Iter1 __first1,
48       _Sent1 __last1,
49       _Iter2 __first2,
50       _Sent2 __last2,
51       _Comp __comp   = {},
52       _Proj1 __proj1 = {},
53       _Proj2 __proj2 = {}) const {
54     return std::__includes(
55         std::move(__first1),
56         std::move(__last1),
57         std::move(__first2),
58         std::move(__last2),
59         std::move(__comp),
60         std::move(__proj1),
61         std::move(__proj2));
62   }
63 
64   template <input_range _Range1,
65             input_range _Range2,
66             class _Proj1 = identity,
67             class _Proj2 = identity,
68             indirect_strict_weak_order<projected<iterator_t<_Range1>, _Proj1>, projected<iterator_t<_Range2>, _Proj2>>
69                 _Comp = ranges::less>
70   [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool operator()(
71       _Range1&& __range1, _Range2&& __range2, _Comp __comp = {}, _Proj1 __proj1 = {}, _Proj2 __proj2 = {}) const {
72     return std::__includes(
73         ranges::begin(__range1),
74         ranges::end(__range1),
75         ranges::begin(__range2),
76         ranges::end(__range2),
77         std::move(__comp),
78         std::move(__proj1),
79         std::move(__proj2));
80   }
81 };
82 
83 inline namespace __cpo {
84 inline constexpr auto includes = __includes{};
85 } // namespace __cpo
86 } // namespace ranges
87 
88 _LIBCPP_END_NAMESPACE_STD
89 
90 #endif // _LIBCPP_STD_VER >= 20
91 
92 _LIBCPP_POP_MACROS
93 
94 #endif // _LIBCPP___ALGORITHM_RANGES_INCLUDES_H
95