Path: blob/main/contrib/llvm-project/libcxx/include/__random/is_valid.h
35233 views
//===----------------------------------------------------------------------===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//78#ifndef _LIBCPP___RANDOM_IS_VALID_H9#define _LIBCPP___RANDOM_IS_VALID_H1011#include <__config>12#include <__type_traits/enable_if.h>13#include <__type_traits/integral_constant.h>14#include <__type_traits/is_same.h>15#include <__type_traits/is_unsigned.h>16#include <__utility/declval.h>17#include <cstdint>1819#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)20# pragma GCC system_header21#endif2223_LIBCPP_BEGIN_NAMESPACE_STD2425// [rand.req.genl]/1.4:26// The effect of instantiating a template that has a template type parameter27// named RealType is undefined unless the corresponding template argument is28// cv-unqualified and is one of float, double, or long double.2930template <class>31struct __libcpp_random_is_valid_realtype : false_type {};32template <>33struct __libcpp_random_is_valid_realtype<float> : true_type {};34template <>35struct __libcpp_random_is_valid_realtype<double> : true_type {};36template <>37struct __libcpp_random_is_valid_realtype<long double> : true_type {};3839// [rand.req.genl]/1.5:40// The effect of instantiating a template that has a template type parameter41// named IntType is undefined unless the corresponding template argument is42// cv-unqualified and is one of short, int, long, long long, unsigned short,43// unsigned int, unsigned long, or unsigned long long.4445template <class>46struct __libcpp_random_is_valid_inttype : false_type {};47template <>48struct __libcpp_random_is_valid_inttype<int8_t> : true_type {}; // extension49template <>50struct __libcpp_random_is_valid_inttype<short> : true_type {};51template <>52struct __libcpp_random_is_valid_inttype<int> : true_type {};53template <>54struct __libcpp_random_is_valid_inttype<long> : true_type {};55template <>56struct __libcpp_random_is_valid_inttype<long long> : true_type {};57template <>58struct __libcpp_random_is_valid_inttype<uint8_t> : true_type {}; // extension59template <>60struct __libcpp_random_is_valid_inttype<unsigned short> : true_type {};61template <>62struct __libcpp_random_is_valid_inttype<unsigned int> : true_type {};63template <>64struct __libcpp_random_is_valid_inttype<unsigned long> : true_type {};65template <>66struct __libcpp_random_is_valid_inttype<unsigned long long> : true_type {};6768#ifndef _LIBCPP_HAS_NO_INT12869template <>70struct __libcpp_random_is_valid_inttype<__int128_t> : true_type {}; // extension71template <>72struct __libcpp_random_is_valid_inttype<__uint128_t> : true_type {}; // extension73#endif // _LIBCPP_HAS_NO_INT1287475// [rand.req.urng]/3:76// A class G meets the uniform random bit generator requirements if G models77// uniform_random_bit_generator, invoke_result_t<G&> is an unsigned integer type,78// and G provides a nested typedef-name result_type that denotes the same type79// as invoke_result_t<G&>.80// (In particular, reject URNGs with signed result_types; our distributions cannot81// handle such generator types.)8283template <class, class = void>84struct __libcpp_random_is_valid_urng : false_type {};85template <class _Gp>86struct __libcpp_random_is_valid_urng<87_Gp,88__enable_if_t< is_unsigned<typename _Gp::result_type>::value &&89_IsSame<decltype(std::declval<_Gp&>()()), typename _Gp::result_type>::value > > : true_type {};9091_LIBCPP_END_NAMESPACE_STD9293#endif // _LIBCPP___RANDOM_IS_VALID_H949596