Warning: This file is not a C or C++ file. It does not have highlighting.
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_COPY_IF_H |
10 | #define _LIBCPP___ALGORITHM_RANGES_COPY_IF_H |
11 | |
12 | #include <__algorithm/copy_if.h> |
13 | #include <__algorithm/in_out_result.h> |
14 | #include <__config> |
15 | #include <__functional/identity.h> |
16 | #include <__functional/invoke.h> |
17 | #include <__iterator/concepts.h> |
18 | #include <__iterator/projected.h> |
19 | #include <__ranges/access.h> |
20 | #include <__ranges/concepts.h> |
21 | #include <__ranges/dangling.h> |
22 | #include <__utility/move.h> |
23 | |
24 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
25 | # pragma GCC system_header |
26 | #endif |
27 | |
28 | _LIBCPP_PUSH_MACROS |
29 | #include <__undef_macros> |
30 | |
31 | #if _LIBCPP_STD_VER >= 20 |
32 | |
33 | _LIBCPP_BEGIN_NAMESPACE_STD |
34 | |
35 | namespace ranges { |
36 | |
37 | template <class _Ip, class _Op> |
38 | using copy_if_result = in_out_result<_Ip, _Op>; |
39 | |
40 | struct __copy_if { |
41 | template <input_iterator _Iter, |
42 | sentinel_for<_Iter> _Sent, |
43 | weakly_incrementable _OutIter, |
44 | class _Proj = identity, |
45 | indirect_unary_predicate<projected<_Iter, _Proj>> _Pred> |
46 | requires indirectly_copyable<_Iter, _OutIter> |
47 | _LIBCPP_HIDE_FROM_ABI constexpr copy_if_result<_Iter, _OutIter> |
48 | operator()(_Iter __first, _Sent __last, _OutIter __result, _Pred __pred, _Proj __proj = {}) const { |
49 | auto __res = std::__copy_if(std::move(__first), std::move(__last), std::move(__result), __pred, __proj); |
50 | return {std::move(__res.first), std::move(__res.second)}; |
51 | } |
52 | |
53 | template <input_range _Range, |
54 | weakly_incrementable _OutIter, |
55 | class _Proj = identity, |
56 | indirect_unary_predicate<projected<iterator_t<_Range>, _Proj>> _Pred> |
57 | requires indirectly_copyable<iterator_t<_Range>, _OutIter> |
58 | _LIBCPP_HIDE_FROM_ABI constexpr copy_if_result<borrowed_iterator_t<_Range>, _OutIter> |
59 | operator()(_Range&& __r, _OutIter __result, _Pred __pred, _Proj __proj = {}) const { |
60 | auto __res = std::__copy_if(ranges::begin(__r), ranges::end(__r), std::move(__result), __pred, __proj); |
61 | return {std::move(__res.first), std::move(__res.second)}; |
62 | } |
63 | }; |
64 | |
65 | inline namespace __cpo { |
66 | inline constexpr auto copy_if = __copy_if{}; |
67 | } // namespace __cpo |
68 | } // namespace ranges |
69 | |
70 | _LIBCPP_END_NAMESPACE_STD |
71 | |
72 | #endif // _LIBCPP_STD_VER >= 20 |
73 | |
74 | _LIBCPP_POP_MACROS |
75 | |
76 | #endif // _LIBCPP___ALGORITHM_RANGES_COPY_IF_H |
77 |
Warning: This file is not a C or C++ file. It does not have highlighting.