[rtsan] Remove mkfifoat interceptor (#116997)
[llvm-project.git] / libcxx / include / __cxx03 / __algorithm / ranges_replace_copy.h
blobd90715d3661baf9ac9f121791a33d4049492198b
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 //===----------------------------------------------------------------------===//
9 #ifndef _LIBCPP___ALGORITHM_RANGES_REPLACE_COPY_H
10 #define _LIBCPP___ALGORITHM_RANGES_REPLACE_COPY_H
12 #include <__cxx03/__algorithm/in_out_result.h>
13 #include <__cxx03/__algorithm/ranges_replace_copy_if.h>
14 #include <__cxx03/__config>
15 #include <__cxx03/__functional/identity.h>
16 #include <__cxx03/__functional/invoke.h>
17 #include <__cxx03/__functional/ranges_operations.h>
18 #include <__cxx03/__iterator/concepts.h>
19 #include <__cxx03/__iterator/projected.h>
20 #include <__cxx03/__ranges/access.h>
21 #include <__cxx03/__ranges/concepts.h>
22 #include <__cxx03/__ranges/dangling.h>
23 #include <__cxx03/__utility/move.h>
25 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
26 # pragma GCC system_header
27 #endif
29 _LIBCPP_PUSH_MACROS
30 #include <__cxx03/__undef_macros>
32 #if _LIBCPP_STD_VER >= 20
34 _LIBCPP_BEGIN_NAMESPACE_STD
36 namespace ranges {
38 template <class _InIter, class _OutIter>
39 using replace_copy_result = in_out_result<_InIter, _OutIter>;
41 namespace __replace_copy {
43 struct __fn {
44 template <input_iterator _InIter,
45 sentinel_for<_InIter> _Sent,
46 class _OldType,
47 class _NewType,
48 output_iterator<const _NewType&> _OutIter,
49 class _Proj = identity>
50 requires indirectly_copyable<_InIter, _OutIter> &&
51 indirect_binary_predicate<ranges::equal_to, projected<_InIter, _Proj>, const _OldType*>
52 _LIBCPP_HIDE_FROM_ABI constexpr replace_copy_result<_InIter, _OutIter>
53 operator()(_InIter __first,
54 _Sent __last,
55 _OutIter __result,
56 const _OldType& __old_value,
57 const _NewType& __new_value,
58 _Proj __proj = {}) const {
59 auto __pred = [&](const auto& __value) -> bool { return __value == __old_value; };
60 return ranges::__replace_copy_if_impl(
61 std::move(__first), std::move(__last), std::move(__result), __pred, __new_value, __proj);
64 template <input_range _Range,
65 class _OldType,
66 class _NewType,
67 output_iterator<const _NewType&> _OutIter,
68 class _Proj = identity>
69 requires indirectly_copyable<iterator_t<_Range>, _OutIter> &&
70 indirect_binary_predicate<ranges::equal_to, projected<iterator_t<_Range>, _Proj>, const _OldType*>
71 _LIBCPP_HIDE_FROM_ABI constexpr replace_copy_result<borrowed_iterator_t<_Range>, _OutIter> operator()(
72 _Range&& __range, _OutIter __result, const _OldType& __old_value, const _NewType& __new_value, _Proj __proj = {})
73 const {
74 auto __pred = [&](const auto& __value) -> bool { return __value == __old_value; };
75 return ranges::__replace_copy_if_impl(
76 ranges::begin(__range), ranges::end(__range), std::move(__result), __pred, __new_value, __proj);
80 } // namespace __replace_copy
82 inline namespace __cpo {
83 inline constexpr auto replace_copy = __replace_copy::__fn{};
84 } // namespace __cpo
85 } // namespace ranges
87 _LIBCPP_END_NAMESPACE_STD
89 #endif // _LIBCPP_STD_VER >= 20
91 _LIBCPP_POP_MACROS
93 #endif // _LIBCPP___ALGORITHM_RANGES_REPLACE_COPY_H