brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.9 KiB · 54581af Raw
81 lines · c
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-exception6//7//===----------------------------------------------------------------------===//8 9#ifndef _LIBCPP___ALGORITHM_RANGES_INPLACE_MERGE_H10#define _LIBCPP___ALGORITHM_RANGES_INPLACE_MERGE_H11 12#include <__algorithm/inplace_merge.h>13#include <__algorithm/iterator_operations.h>14#include <__algorithm/make_projected.h>15#include <__config>16#include <__functional/identity.h>17#include <__functional/invoke.h>18#include <__functional/ranges_operations.h>19#include <__iterator/concepts.h>20#include <__iterator/iterator_traits.h>21#include <__iterator/next.h>22#include <__iterator/projected.h>23#include <__iterator/sortable.h>24#include <__ranges/access.h>25#include <__ranges/concepts.h>26#include <__ranges/dangling.h>27#include <__utility/forward.h>28#include <__utility/move.h>29 30#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)31#  pragma GCC system_header32#endif33 34_LIBCPP_PUSH_MACROS35#include <__undef_macros>36 37#if _LIBCPP_STD_VER >= 2038 39_LIBCPP_BEGIN_NAMESPACE_STD40 41namespace ranges {42struct __inplace_merge {43  template <class _Iter, class _Sent, class _Comp, class _Proj>44  _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR_SINCE_CXX26 auto45  __inplace_merge_impl(_Iter __first, _Iter __middle, _Sent __last, _Comp&& __comp, _Proj&& __proj) {46    auto __last_iter = ranges::next(__middle, __last);47    std::__inplace_merge<_RangeAlgPolicy>(48        std::move(__first), std::move(__middle), __last_iter, std::__make_projected(__comp, __proj));49    return __last_iter;50  }51 52  template <bidirectional_iterator _Iter, sentinel_for<_Iter> _Sent, class _Comp = ranges::less, class _Proj = identity>53    requires sortable<_Iter, _Comp, _Proj>54  _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 _Iter55  operator()(_Iter __first, _Iter __middle, _Sent __last, _Comp __comp = {}, _Proj __proj = {}) const {56    return __inplace_merge_impl(57        std::move(__first), std::move(__middle), std::move(__last), std::move(__comp), std::move(__proj));58  }59 60  template <bidirectional_range _Range, class _Comp = ranges::less, class _Proj = identity>61    requires sortable<iterator_t<_Range>, _Comp, _Proj>62  _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 borrowed_iterator_t<_Range>63  operator()(_Range&& __range, iterator_t<_Range> __middle, _Comp __comp = {}, _Proj __proj = {}) const {64    return __inplace_merge_impl(65        ranges::begin(__range), std::move(__middle), ranges::end(__range), std::move(__comp), std::move(__proj));66  }67};68 69inline namespace __cpo {70inline constexpr auto inplace_merge = __inplace_merge{};71} // namespace __cpo72} // namespace ranges73 74_LIBCPP_END_NAMESPACE_STD75 76#endif // _LIBCPP_STD_VER >= 2077 78_LIBCPP_POP_MACROS79 80#endif // _LIBCPP___ALGORITHM_RANGES_INPLACE_MERGE_H81