Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-03 08:13:10

0001 //===----------------------------------------------------------------------===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 
0009 #ifndef _LIBCPP___ALGORITHM_RANGES_INPLACE_MERGE_H
0010 #define _LIBCPP___ALGORITHM_RANGES_INPLACE_MERGE_H
0011 
0012 #include <__algorithm/inplace_merge.h>
0013 #include <__algorithm/iterator_operations.h>
0014 #include <__algorithm/make_projected.h>
0015 #include <__config>
0016 #include <__functional/identity.h>
0017 #include <__functional/invoke.h>
0018 #include <__functional/ranges_operations.h>
0019 #include <__iterator/concepts.h>
0020 #include <__iterator/iterator_traits.h>
0021 #include <__iterator/next.h>
0022 #include <__iterator/projected.h>
0023 #include <__iterator/sortable.h>
0024 #include <__ranges/access.h>
0025 #include <__ranges/concepts.h>
0026 #include <__ranges/dangling.h>
0027 #include <__utility/forward.h>
0028 #include <__utility/move.h>
0029 
0030 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
0031 #  pragma GCC system_header
0032 #endif
0033 
0034 _LIBCPP_PUSH_MACROS
0035 #include <__undef_macros>
0036 
0037 #if _LIBCPP_STD_VER >= 20
0038 
0039 _LIBCPP_BEGIN_NAMESPACE_STD
0040 
0041 namespace ranges {
0042 struct __inplace_merge {
0043   template <class _Iter, class _Sent, class _Comp, class _Proj>
0044   _LIBCPP_HIDE_FROM_ABI static constexpr auto
0045   __inplace_merge_impl(_Iter __first, _Iter __middle, _Sent __last, _Comp&& __comp, _Proj&& __proj) {
0046     auto __last_iter = ranges::next(__middle, __last);
0047     std::__inplace_merge<_RangeAlgPolicy>(
0048         std::move(__first), std::move(__middle), __last_iter, std::__make_projected(__comp, __proj));
0049     return __last_iter;
0050   }
0051 
0052   template <bidirectional_iterator _Iter, sentinel_for<_Iter> _Sent, class _Comp = ranges::less, class _Proj = identity>
0053     requires sortable<_Iter, _Comp, _Proj>
0054   _LIBCPP_HIDE_FROM_ABI _Iter
0055   operator()(_Iter __first, _Iter __middle, _Sent __last, _Comp __comp = {}, _Proj __proj = {}) const {
0056     return __inplace_merge_impl(
0057         std::move(__first), std::move(__middle), std::move(__last), std::move(__comp), std::move(__proj));
0058   }
0059 
0060   template <bidirectional_range _Range, class _Comp = ranges::less, class _Proj = identity>
0061     requires sortable<iterator_t<_Range>, _Comp, _Proj>
0062   _LIBCPP_HIDE_FROM_ABI borrowed_iterator_t<_Range>
0063   operator()(_Range&& __range, iterator_t<_Range> __middle, _Comp __comp = {}, _Proj __proj = {}) const {
0064     return __inplace_merge_impl(
0065         ranges::begin(__range), std::move(__middle), ranges::end(__range), std::move(__comp), std::move(__proj));
0066   }
0067 };
0068 
0069 inline namespace __cpo {
0070 inline constexpr auto inplace_merge = __inplace_merge{};
0071 } // namespace __cpo
0072 } // namespace ranges
0073 
0074 _LIBCPP_END_NAMESPACE_STD
0075 
0076 #endif // _LIBCPP_STD_VER >= 20
0077 
0078 _LIBCPP_POP_MACROS
0079 
0080 #endif // _LIBCPP___ALGORITHM_RANGES_INPLACE_MERGE_H