Mercurial > hg > CbC > CbC_llvm
comparison libcxx/include/__algorithm/ranges_rotate.h @ 236:c4bab56944e8 llvm-original
LLVM 16
author | kono |
---|---|
date | Wed, 09 Nov 2022 17:45:10 +0900 |
parents | |
children | 1f2b6ac9f198 |
comparison
equal
deleted
inserted
replaced
232:70dce7da266c | 236:c4bab56944e8 |
---|---|
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_ROTATE_H | |
10 #define _LIBCPP___ALGORITHM_RANGES_ROTATE_H | |
11 | |
12 #include <__algorithm/iterator_operations.h> | |
13 #include <__algorithm/ranges_iterator_concept.h> | |
14 #include <__algorithm/rotate.h> | |
15 #include <__config> | |
16 #include <__iterator/concepts.h> | |
17 #include <__iterator/iterator_traits.h> | |
18 #include <__iterator/permutable.h> | |
19 #include <__ranges/access.h> | |
20 #include <__ranges/concepts.h> | |
21 #include <__ranges/subrange.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 #if _LIBCPP_STD_VER > 17 | |
29 | |
30 _LIBCPP_BEGIN_NAMESPACE_STD | |
31 | |
32 namespace ranges { | |
33 namespace __rotate { | |
34 | |
35 struct __fn { | |
36 | |
37 template <class _Iter, class _Sent> | |
38 _LIBCPP_HIDE_FROM_ABI constexpr | |
39 static subrange<_Iter> __rotate_fn_impl(_Iter __first, _Iter __middle, _Sent __last) { | |
40 auto __ret = std::__rotate<_RangeAlgPolicy>( | |
41 std::move(__first), std::move(__middle), std::move(__last)); | |
42 return {std::move(__ret.first), std::move(__ret.second)}; | |
43 } | |
44 | |
45 template <permutable _Iter, sentinel_for<_Iter> _Sent> | |
46 _LIBCPP_HIDE_FROM_ABI constexpr | |
47 subrange<_Iter> operator()(_Iter __first, _Iter __middle, _Sent __last) const { | |
48 return __rotate_fn_impl(std::move(__first), std::move(__middle), std::move(__last)); | |
49 } | |
50 | |
51 template <forward_range _Range> | |
52 requires permutable<iterator_t<_Range>> | |
53 _LIBCPP_HIDE_FROM_ABI constexpr | |
54 borrowed_subrange_t<_Range> operator()(_Range&& __range, iterator_t<_Range> __middle) const { | |
55 return __rotate_fn_impl(ranges::begin(__range), std::move(__middle), ranges::end(__range)); | |
56 } | |
57 | |
58 }; | |
59 | |
60 } // namespace __rotate | |
61 | |
62 inline namespace __cpo { | |
63 inline constexpr auto rotate = __rotate::__fn{}; | |
64 } // namespace __cpo | |
65 } // namespace ranges | |
66 | |
67 _LIBCPP_END_NAMESPACE_STD | |
68 | |
69 #endif // _LIBCPP_STD_VER > 17 | |
70 | |
71 #endif // _LIBCPP___ALGORITHM_RANGES_ROTATE_H |