| 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_N_H |
| 10 | #define _LIBCPP___ALGORITHM_RANGES_COPY_N_H |
| 11 | |
| 12 | #include <__algorithm/copy_n.h> |
| 13 | #include <__algorithm/in_out_result.h> |
| 14 | #include <__algorithm/iterator_operations.h> |
| 15 | #include <__config> |
| 16 | #include <__iterator/concepts.h> |
| 17 | #include <__iterator/incrementable_traits.h> |
| 18 | #include <__utility/move.h> |
| 19 | |
| 20 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 21 | # pragma GCC system_header |
| 22 | #endif |
| 23 | |
| 24 | _LIBCPP_PUSH_MACROS |
| 25 | #include <__undef_macros> |
| 26 | |
| 27 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 28 | |
| 29 | #if _LIBCPP_STD_VER >= 20 |
| 30 | |
| 31 | namespace ranges { |
| 32 | |
| 33 | template <class _Ip, class _Op> |
| 34 | using copy_n_result = in_out_result<_Ip, _Op>; |
| 35 | |
| 36 | struct __copy_n { |
| 37 | template <input_iterator _Ip, weakly_incrementable _Op> |
| 38 | requires indirectly_copyable<_Ip, _Op> |
| 39 | _LIBCPP_HIDE_FROM_ABI constexpr copy_n_result<_Ip, _Op> |
| 40 | operator()(_Ip __first, iter_difference_t<_Ip> __n, _Op __result) const { |
| 41 | auto __res = std::__copy_n<_RangeAlgPolicy>(std::move(__first), __n, std::move(__result)); |
| 42 | return {std::move(__res.first), std::move(__res.second)}; |
| 43 | } |
| 44 | }; |
| 45 | |
| 46 | inline namespace __cpo { |
| 47 | inline constexpr auto copy_n = __copy_n{}; |
| 48 | } // namespace __cpo |
| 49 | } // namespace ranges |
| 50 | |
| 51 | #endif // _LIBCPP_STD_VER >= 20 |
| 52 | |
| 53 | _LIBCPP_END_NAMESPACE_STD |
| 54 | |
| 55 | _LIBCPP_POP_MACROS |
| 56 | |
| 57 | #endif // _LIBCPP___ALGORITHM_RANGES_COPY_N_H |
| 58 | |