brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.3 KiB · 87cb368 Raw
69 lines · c
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-exception6//7//===----------------------------------------------------------------------===//8 9#ifndef _LIBCPP___ALGORITHM_RANGES_SHUFFLE_H10#define _LIBCPP___ALGORITHM_RANGES_SHUFFLE_H11 12#include <__algorithm/iterator_operations.h>13#include <__algorithm/shuffle.h>14#include <__algorithm/uniform_random_bit_generator_adaptor.h>15#include <__config>16#include <__functional/invoke.h>17#include <__functional/ranges_operations.h>18#include <__iterator/concepts.h>19#include <__iterator/iterator_traits.h>20#include <__iterator/next.h>21#include <__iterator/permutable.h>22#include <__random/uniform_random_bit_generator.h>23#include <__ranges/access.h>24#include <__ranges/concepts.h>25#include <__ranges/dangling.h>26#include <__type_traits/remove_reference.h>27#include <__utility/forward.h>28#include <__utility/move.h>29 30#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)31#  pragma GCC system_header32#endif33 34_LIBCPP_PUSH_MACROS35#include <__undef_macros>36 37#if _LIBCPP_STD_VER >= 2038 39_LIBCPP_BEGIN_NAMESPACE_STD40 41namespace ranges {42struct __shuffle {43  template <random_access_iterator _Iter, sentinel_for<_Iter> _Sent, class _Gen>44    requires permutable<_Iter> && uniform_random_bit_generator<remove_reference_t<_Gen>>45  _LIBCPP_HIDE_FROM_ABI _Iter operator()(_Iter __first, _Sent __last, _Gen&& __gen) const {46    _ClassicGenAdaptor<_Gen> __adapted_gen(__gen);47    return std::__shuffle<_RangeAlgPolicy>(std::move(__first), std::move(__last), __adapted_gen);48  }49 50  template <random_access_range _Range, class _Gen>51    requires permutable<iterator_t<_Range>> && uniform_random_bit_generator<remove_reference_t<_Gen>>52  _LIBCPP_HIDE_FROM_ABI borrowed_iterator_t<_Range> operator()(_Range&& __range, _Gen&& __gen) const {53    return (*this)(ranges::begin(__range), ranges::end(__range), std::forward<_Gen>(__gen));54  }55};56 57inline namespace __cpo {58inline constexpr auto shuffle = __shuffle{};59} // namespace __cpo60} // namespace ranges61 62_LIBCPP_END_NAMESPACE_STD63 64#endif // _LIBCPP_STD_VER >= 2065 66_LIBCPP_POP_MACROS67 68#endif // _LIBCPP___ALGORITHM_RANGES_SHUFFLE_H69