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_REMOVE_COPY_H
10#define _LIBCPP___ALGORITHM_RANGES_REMOVE_COPY_H
11
12#include <__algorithm/in_out_result.h>
13#include <__algorithm/ranges_remove_copy_if.h>
14#include <__config>
15#include <__functional/identity.h>
16#include <__functional/invoke.h>
17#include <__functional/ranges_operations.h>
18#include <__iterator/concepts.h>
19#include <__iterator/projected.h>
20#include <__ranges/access.h>
21#include <__ranges/concepts.h>
22#include <__ranges/dangling.h>
23#include <__utility/move.h>
24
25#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
26#  pragma GCC system_header
27#endif
28
29#if _LIBCPP_STD_VER > 17
30
31_LIBCPP_BEGIN_NAMESPACE_STD
32
33namespace ranges {
34
35template <class _InIter, class _OutIter>
36using remove_copy_result = in_out_result<_InIter, _OutIter>;
37
38namespace __remove_copy {
39
40  struct __fn {
41    template <input_iterator _InIter,
42              sentinel_for<_InIter> _Sent,
43              weakly_incrementable _OutIter,
44              class _Type,
45              class _Proj = identity>
46      requires indirectly_copyable<_InIter, _OutIter> &&
47               indirect_binary_predicate<ranges::equal_to, projected<_InIter, _Proj>, const _Type*>
48    _LIBCPP_HIDE_FROM_ABI constexpr remove_copy_result<_InIter, _OutIter>
49    operator()(_InIter __first, _Sent __last, _OutIter __result, const _Type& __value, _Proj __proj = {}) const {
50      auto __pred = [&](auto&& __val) { return __value == __val; };
51      return ranges::__remove_copy_if_impl(std::move(__first), std::move(__last), std::move(__result), __pred, __proj);
52    }
53
54    template <input_range _Range, weakly_incrementable _OutIter, class _Type, class _Proj = identity>
55      requires indirectly_copyable<iterator_t<_Range>, _OutIter> &&
56               indirect_binary_predicate<ranges::equal_to, projected<iterator_t<_Range>, _Proj>, const _Type*>
57    _LIBCPP_HIDE_FROM_ABI constexpr remove_copy_result<borrowed_iterator_t<_Range>, _OutIter>
58    operator()(_Range&& __range, _OutIter __result, const _Type& __value, _Proj __proj = {}) const {
59      auto __pred = [&](auto&& __val) { return __value == __val; };
60      return ranges::__remove_copy_if_impl(
61          ranges::begin(__range), ranges::end(__range), std::move(__result), __pred, __proj);
62    }
63  };
64
65} // namespace __remove_copy
66
67inline namespace __cpo {
68  inline constexpr auto remove_copy = __remove_copy::__fn{};
69} // namespace __cpo
70} // namespace ranges
71
72_LIBCPP_END_NAMESPACE_STD
73
74#endif // _LIBCPP_STD_VER > 17
75
76#endif // _LIBCPP___ALGORITHM_RANGES_REMOVE_COPY_H
77