Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-03 08:13:21

0001 //===----------------------------------------------------------------------===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 
0009 #ifndef _LIBCPP___CXX03___ALGORITHM_RANGES_SHUFFLE_H
0010 #define _LIBCPP___CXX03___ALGORITHM_RANGES_SHUFFLE_H
0011 
0012 #include <__cxx03/__algorithm/iterator_operations.h>
0013 #include <__cxx03/__algorithm/shuffle.h>
0014 #include <__cxx03/__algorithm/uniform_random_bit_generator_adaptor.h>
0015 #include <__cxx03/__config>
0016 #include <__cxx03/__functional/invoke.h>
0017 #include <__cxx03/__functional/ranges_operations.h>
0018 #include <__cxx03/__iterator/concepts.h>
0019 #include <__cxx03/__iterator/iterator_traits.h>
0020 #include <__cxx03/__iterator/next.h>
0021 #include <__cxx03/__iterator/permutable.h>
0022 #include <__cxx03/__random/uniform_random_bit_generator.h>
0023 #include <__cxx03/__ranges/access.h>
0024 #include <__cxx03/__ranges/concepts.h>
0025 #include <__cxx03/__ranges/dangling.h>
0026 #include <__cxx03/__type_traits/remove_reference.h>
0027 #include <__cxx03/__utility/forward.h>
0028 #include <__cxx03/__utility/move.h>
0029 
0030 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
0031 #  pragma GCC system_header
0032 #endif
0033 
0034 _LIBCPP_PUSH_MACROS
0035 #include <__cxx03/__undef_macros>
0036 
0037 #if _LIBCPP_STD_VER >= 20
0038 
0039 _LIBCPP_BEGIN_NAMESPACE_STD
0040 
0041 namespace ranges {
0042 namespace __shuffle {
0043 
0044 struct __fn {
0045   template <random_access_iterator _Iter, sentinel_for<_Iter> _Sent, class _Gen>
0046     requires permutable<_Iter> && uniform_random_bit_generator<remove_reference_t<_Gen>>
0047   _LIBCPP_HIDE_FROM_ABI _Iter operator()(_Iter __first, _Sent __last, _Gen&& __gen) const {
0048     _ClassicGenAdaptor<_Gen> __adapted_gen(__gen);
0049     return std::__shuffle<_RangeAlgPolicy>(std::move(__first), std::move(__last), __adapted_gen);
0050   }
0051 
0052   template <random_access_range _Range, class _Gen>
0053     requires permutable<iterator_t<_Range>> && uniform_random_bit_generator<remove_reference_t<_Gen>>
0054   _LIBCPP_HIDE_FROM_ABI borrowed_iterator_t<_Range> operator()(_Range&& __range, _Gen&& __gen) const {
0055     return (*this)(ranges::begin(__range), ranges::end(__range), std::forward<_Gen>(__gen));
0056   }
0057 };
0058 
0059 } // namespace __shuffle
0060 
0061 inline namespace __cpo {
0062 inline constexpr auto shuffle = __shuffle::__fn{};
0063 } // namespace __cpo
0064 } // namespace ranges
0065 
0066 _LIBCPP_END_NAMESPACE_STD
0067 
0068 #endif // _LIBCPP_STD_VER >= 20
0069 
0070 _LIBCPP_POP_MACROS
0071 
0072 #endif // _LIBCPP___CXX03___ALGORITHM_RANGES_SHUFFLE_H