AMDGPU: Fix verifier assert with out of bounds subregister indexes (#119799)
[llvm-project.git] / libcxx / include / __cxx03 / __algorithm / ranges_generate_n.h
blobdd43e21618718d90e69ba3f367001be4a3cb76e7
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___CXX03___ALGORITHM_RANGES_GENERATE_N_H
10 #define _LIBCPP___CXX03___ALGORITHM_RANGES_GENERATE_N_H
12 #include <__cxx03/__concepts/constructible.h>
13 #include <__cxx03/__concepts/invocable.h>
14 #include <__cxx03/__config>
15 #include <__cxx03/__functional/identity.h>
16 #include <__cxx03/__functional/invoke.h>
17 #include <__cxx03/__iterator/concepts.h>
18 #include <__cxx03/__iterator/incrementable_traits.h>
19 #include <__cxx03/__iterator/iterator_traits.h>
20 #include <__cxx03/__ranges/access.h>
21 #include <__cxx03/__ranges/concepts.h>
22 #include <__cxx03/__utility/move.h>
24 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
25 # pragma GCC system_header
26 #endif
28 _LIBCPP_PUSH_MACROS
29 #include <__cxx03/__undef_macros>
31 #if _LIBCPP_STD_VER >= 20
33 _LIBCPP_BEGIN_NAMESPACE_STD
35 namespace ranges {
36 namespace __generate_n {
38 struct __fn {
39 template <input_or_output_iterator _OutIter, copy_constructible _Func>
40 requires invocable<_Func&> && indirectly_writable<_OutIter, invoke_result_t<_Func&>>
41 _LIBCPP_HIDE_FROM_ABI constexpr _OutIter
42 operator()(_OutIter __first, iter_difference_t<_OutIter> __n, _Func __gen) const {
43 for (; __n > 0; --__n) {
44 *__first = __gen();
45 ++__first;
48 return __first;
52 } // namespace __generate_n
54 inline namespace __cpo {
55 inline constexpr auto generate_n = __generate_n::__fn{};
56 } // namespace __cpo
57 } // namespace ranges
59 _LIBCPP_END_NAMESPACE_STD
61 #endif // _LIBCPP_STD_VER >= 20
63 _LIBCPP_POP_MACROS
65 #endif // _LIBCPP___CXX03___ALGORITHM_RANGES_GENERATE_N_H