xref: /freebsd/contrib/llvm-project/libcxx/include/__algorithm/ranges_move.h (revision b3edf4467982447620505a28fc82e38a414c07dc)
181ad6265SDimitry Andric //===----------------------------------------------------------------------===//
281ad6265SDimitry Andric //
381ad6265SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
481ad6265SDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
581ad6265SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
681ad6265SDimitry Andric //
781ad6265SDimitry Andric //===----------------------------------------------------------------------===//
881ad6265SDimitry Andric 
981ad6265SDimitry Andric #ifndef _LIBCPP___ALGORITHM_RANGES_MOVE_H
1081ad6265SDimitry Andric #define _LIBCPP___ALGORITHM_RANGES_MOVE_H
1181ad6265SDimitry Andric 
1281ad6265SDimitry Andric #include <__algorithm/in_out_result.h>
1361cfbce3SDimitry Andric #include <__algorithm/iterator_operations.h>
1481ad6265SDimitry Andric #include <__algorithm/move.h>
1581ad6265SDimitry Andric #include <__config>
1681ad6265SDimitry Andric #include <__iterator/concepts.h>
1781ad6265SDimitry Andric #include <__ranges/access.h>
1881ad6265SDimitry Andric #include <__ranges/concepts.h>
1981ad6265SDimitry Andric #include <__ranges/dangling.h>
2081ad6265SDimitry Andric #include <__utility/move.h>
2181ad6265SDimitry Andric 
2281ad6265SDimitry Andric #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
2381ad6265SDimitry Andric #  pragma GCC system_header
2481ad6265SDimitry Andric #endif
2581ad6265SDimitry Andric 
26*b3edf446SDimitry Andric _LIBCPP_PUSH_MACROS
27*b3edf446SDimitry Andric #include <__undef_macros>
28*b3edf446SDimitry Andric 
2906c3fb27SDimitry Andric #if _LIBCPP_STD_VER >= 20
3081ad6265SDimitry Andric 
3181ad6265SDimitry Andric _LIBCPP_BEGIN_NAMESPACE_STD
3281ad6265SDimitry Andric 
3381ad6265SDimitry Andric namespace ranges {
3481ad6265SDimitry Andric 
3581ad6265SDimitry Andric template <class _InIter, class _OutIter>
3681ad6265SDimitry Andric using move_result = in_out_result<_InIter, _OutIter>;
3781ad6265SDimitry Andric 
3881ad6265SDimitry Andric namespace __move {
3981ad6265SDimitry Andric struct __fn {
4081ad6265SDimitry Andric   template <class _InIter, class _Sent, class _OutIter>
4106c3fb27SDimitry Andric   _LIBCPP_HIDE_FROM_ABI constexpr static move_result<_InIter, _OutIter>
4206c3fb27SDimitry Andric   __move_impl(_InIter __first, _Sent __last, _OutIter __result) {
4361cfbce3SDimitry Andric     auto __ret = std::__move<_RangeAlgPolicy>(std::move(__first), std::move(__last), std::move(__result));
4481ad6265SDimitry Andric     return {std::move(__ret.first), std::move(__ret.second)};
4581ad6265SDimitry Andric   }
4681ad6265SDimitry Andric 
4781ad6265SDimitry Andric   template <input_iterator _InIter, sentinel_for<_InIter> _Sent, weakly_incrementable _OutIter>
4881ad6265SDimitry Andric     requires indirectly_movable<_InIter, _OutIter>
4906c3fb27SDimitry Andric   _LIBCPP_HIDE_FROM_ABI constexpr move_result<_InIter, _OutIter>
5006c3fb27SDimitry Andric   operator()(_InIter __first, _Sent __last, _OutIter __result) const {
5181ad6265SDimitry Andric     return __move_impl(std::move(__first), std::move(__last), std::move(__result));
5281ad6265SDimitry Andric   }
5381ad6265SDimitry Andric 
5481ad6265SDimitry Andric   template <input_range _Range, weakly_incrementable _OutIter>
5581ad6265SDimitry Andric     requires indirectly_movable<iterator_t<_Range>, _OutIter>
5606c3fb27SDimitry Andric   _LIBCPP_HIDE_FROM_ABI constexpr move_result<borrowed_iterator_t<_Range>, _OutIter>
5706c3fb27SDimitry Andric   operator()(_Range&& __range, _OutIter __result) const {
5881ad6265SDimitry Andric     return __move_impl(ranges::begin(__range), ranges::end(__range), std::move(__result));
5981ad6265SDimitry Andric   }
6081ad6265SDimitry Andric };
6181ad6265SDimitry Andric } // namespace __move
6281ad6265SDimitry Andric 
6381ad6265SDimitry Andric inline namespace __cpo {
6481ad6265SDimitry Andric inline constexpr auto move = __move::__fn{};
6581ad6265SDimitry Andric } // namespace __cpo
6681ad6265SDimitry Andric } // namespace ranges
6781ad6265SDimitry Andric 
6881ad6265SDimitry Andric _LIBCPP_END_NAMESPACE_STD
6981ad6265SDimitry Andric 
7006c3fb27SDimitry Andric #endif // _LIBCPP_STD_VER >= 20
7181ad6265SDimitry Andric 
72*b3edf446SDimitry Andric _LIBCPP_POP_MACROS
73*b3edf446SDimitry Andric 
7481ad6265SDimitry Andric #endif // _LIBCPP___ALGORITHM_RANGES_MOVE_H
75