1753f127fSDimitry Andric //===----------------------------------------------------------------------===// 2753f127fSDimitry Andric // 3753f127fSDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4753f127fSDimitry Andric // See https://llvm.org/LICENSE.txt for license information. 5753f127fSDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6753f127fSDimitry Andric // 7753f127fSDimitry Andric //===----------------------------------------------------------------------===// 8753f127fSDimitry Andric 9753f127fSDimitry Andric #ifndef _LIBCPP___LIBCXX_DEBUG_RANDOMIZE_RANGE_H 10753f127fSDimitry Andric #define _LIBCPP___LIBCXX_DEBUG_RANDOMIZE_RANGE_H 11753f127fSDimitry Andric 12753f127fSDimitry Andric #include <__config> 13753f127fSDimitry Andric 14753f127fSDimitry Andric #ifdef _LIBCPP_DEBUG_RANDOMIZE_UNSPECIFIED_STABILITY 15753f127fSDimitry Andric # include <__algorithm/shuffle.h> 16753f127fSDimitry Andric # include <__type_traits/is_constant_evaluated.h> 17753f127fSDimitry Andric #endif 18753f127fSDimitry Andric 19753f127fSDimitry Andric #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 20753f127fSDimitry Andric # pragma GCC system_header 21753f127fSDimitry Andric #endif 22753f127fSDimitry Andric 23753f127fSDimitry Andric _LIBCPP_BEGIN_NAMESPACE_STD 24753f127fSDimitry Andric 25fcaf7f86SDimitry Andric template <class _AlgPolicy, class _Iterator, class _Sentinel> 26*cb14a3feSDimitry Andric _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 void __debug_randomize_range(_Iterator __first, _Sentinel __last) { 27753f127fSDimitry Andric #ifdef _LIBCPP_DEBUG_RANDOMIZE_UNSPECIFIED_STABILITY 28753f127fSDimitry Andric # ifdef _LIBCPP_CXX03_LANG 29753f127fSDimitry Andric # error Support for unspecified stability is only for C++11 and higher 30753f127fSDimitry Andric # endif 31753f127fSDimitry Andric 32753f127fSDimitry Andric if (!__libcpp_is_constant_evaluated()) 33fcaf7f86SDimitry Andric std::__shuffle<_AlgPolicy>(__first, __last, __libcpp_debug_randomizer()); 34753f127fSDimitry Andric #else 35753f127fSDimitry Andric (void)__first; 36753f127fSDimitry Andric (void)__last; 37753f127fSDimitry Andric #endif 38753f127fSDimitry Andric } 39753f127fSDimitry Andric 40753f127fSDimitry Andric _LIBCPP_END_NAMESPACE_STD 41753f127fSDimitry Andric 42753f127fSDimitry Andric #endif // _LIBCPP___LIBCXX_DEBUG_RANDOMIZE_RANGE_H 43