[rtsan] Remove mkfifoat interceptor (#116997)
[llvm-project.git] / libcxx / include / __cxx03 / __algorithm / ranges_generate.h
blob570ed73a295503a62ed5ea905c19fb6ff2942534
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_GENERATE_H
10 #define _LIBCPP___ALGORITHM_RANGES_GENERATE_H
12 #include <__cxx03/__concepts/constructible.h>
13 #include <__cxx03/__concepts/invocable.h>
14 #include <__cxx03/__config>
15 #include <__cxx03/__functional/invoke.h>
16 #include <__cxx03/__iterator/concepts.h>
17 #include <__cxx03/__iterator/iterator_traits.h>
18 #include <__cxx03/__ranges/access.h>
19 #include <__cxx03/__ranges/concepts.h>
20 #include <__cxx03/__ranges/dangling.h>
21 #include <__cxx03/__utility/move.h>
23 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
24 # pragma GCC system_header
25 #endif
27 _LIBCPP_PUSH_MACROS
28 #include <__cxx03/__undef_macros>
30 #if _LIBCPP_STD_VER >= 20
32 _LIBCPP_BEGIN_NAMESPACE_STD
34 namespace ranges {
35 namespace __generate {
37 struct __fn {
38 template <class _OutIter, class _Sent, class _Func>
39 _LIBCPP_HIDE_FROM_ABI constexpr static _OutIter __generate_fn_impl(_OutIter __first, _Sent __last, _Func& __gen) {
40 for (; __first != __last; ++__first) {
41 *__first = __gen();
44 return __first;
47 template <input_or_output_iterator _OutIter, sentinel_for<_OutIter> _Sent, copy_constructible _Func>
48 requires invocable<_Func&> && indirectly_writable<_OutIter, invoke_result_t<_Func&>>
49 _LIBCPP_HIDE_FROM_ABI constexpr _OutIter operator()(_OutIter __first, _Sent __last, _Func __gen) const {
50 return __generate_fn_impl(std::move(__first), std::move(__last), __gen);
53 template <class _Range, copy_constructible _Func>
54 requires invocable<_Func&> && output_range<_Range, invoke_result_t<_Func&>>
55 _LIBCPP_HIDE_FROM_ABI constexpr borrowed_iterator_t<_Range> operator()(_Range&& __range, _Func __gen) const {
56 return __generate_fn_impl(ranges::begin(__range), ranges::end(__range), __gen);
60 } // namespace __generate
62 inline namespace __cpo {
63 inline constexpr auto generate = __generate::__fn{};
64 } // namespace __cpo
65 } // namespace ranges
67 _LIBCPP_END_NAMESPACE_STD
69 #endif // _LIBCPP_STD_VER >= 20
71 _LIBCPP_POP_MACROS
73 #endif // _LIBCPP___ALGORITHM_RANGES_GENERATE_H