AMDGPU: Fix verifier assert with out of bounds subregister indexes (#119799)
[llvm-project.git] / libcxx / include / __cxx03 / __algorithm / ranges_sample.h
blob778661c2ce413e30908088f7151188efa18a6418
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_SAMPLE_H
10 #define _LIBCPP___CXX03___ALGORITHM_RANGES_SAMPLE_H
12 #include <__cxx03/__algorithm/iterator_operations.h>
13 #include <__cxx03/__algorithm/sample.h>
14 #include <__cxx03/__algorithm/uniform_random_bit_generator_adaptor.h>
15 #include <__cxx03/__config>
16 #include <__cxx03/__iterator/concepts.h>
17 #include <__cxx03/__iterator/incrementable_traits.h>
18 #include <__cxx03/__iterator/iterator_traits.h>
19 #include <__cxx03/__random/uniform_random_bit_generator.h>
20 #include <__cxx03/__ranges/access.h>
21 #include <__cxx03/__ranges/concepts.h>
22 #include <__cxx03/__type_traits/remove_reference.h>
23 #include <__cxx03/__utility/forward.h>
24 #include <__cxx03/__utility/move.h>
26 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
27 # pragma GCC system_header
28 #endif
30 _LIBCPP_PUSH_MACROS
31 #include <__cxx03/__undef_macros>
33 #if _LIBCPP_STD_VER >= 20
35 _LIBCPP_BEGIN_NAMESPACE_STD
37 namespace ranges {
38 namespace __sample {
40 struct __fn {
41 template <input_iterator _Iter, sentinel_for<_Iter> _Sent, weakly_incrementable _OutIter, class _Gen>
42 requires(forward_iterator<_Iter> || random_access_iterator<_OutIter>) && indirectly_copyable<_Iter, _OutIter> &&
43 uniform_random_bit_generator<remove_reference_t<_Gen>>
44 _LIBCPP_HIDE_FROM_ABI _OutIter
45 operator()(_Iter __first, _Sent __last, _OutIter __out_first, iter_difference_t<_Iter> __n, _Gen&& __gen) const {
46 _ClassicGenAdaptor<_Gen> __adapted_gen(__gen);
47 return std::__sample<_RangeAlgPolicy>(
48 std::move(__first), std::move(__last), std::move(__out_first), __n, __adapted_gen);
51 template <input_range _Range, weakly_incrementable _OutIter, class _Gen>
52 requires(forward_range<_Range> || random_access_iterator<_OutIter>) &&
53 indirectly_copyable<iterator_t<_Range>, _OutIter> && uniform_random_bit_generator<remove_reference_t<_Gen>>
54 _LIBCPP_HIDE_FROM_ABI _OutIter
55 operator()(_Range&& __range, _OutIter __out_first, range_difference_t<_Range> __n, _Gen&& __gen) const {
56 return (*this)(
57 ranges::begin(__range), ranges::end(__range), std::move(__out_first), __n, std::forward<_Gen>(__gen));
61 } // namespace __sample
63 inline namespace __cpo {
64 inline constexpr auto sample = __sample::__fn{};
65 } // namespace __cpo
66 } // namespace ranges
68 _LIBCPP_END_NAMESPACE_STD
70 #endif // _LIBCPP_STD_VER >= 20
72 _LIBCPP_POP_MACROS
74 #endif // _LIBCPP___CXX03___ALGORITHM_RANGES_SAMPLE_H