values.pass.cpp revision b64f8b07c104c6cc986570ac8ee0ed16a9f23976
1//===----------------------------------------------------------------------===// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is dual licensed under the MIT and the University of Illinois Open 6// Source Licenses. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// 9 10// <random> 11 12// template <class UIntType, UIntType a, UIntType c, UIntType m> 13// class linear_congruential_engine 14// { 15// public: 16// engine characteristics 17// static constexpr result_type multiplier = a; 18// static constexpr result_type increment = c; 19// static constexpr result_type modulus = m; 20// static constexpr result_type min() { return c == 0u ? 1u: 0u;} 21// static constexpr result_type max() { return m - 1u;} 22// static constexpr result_type default_seed = 1u; 23 24#include <random> 25#include <type_traits> 26#include <cassert> 27 28template <class T, T a, T c, T m> 29void 30test1() 31{ 32 typedef std::linear_congruential_engine<T, a, c, m> LCE; 33 typedef typename LCE::result_type result_type; 34 static_assert((LCE::multiplier == a), ""); 35 static_assert((LCE::increment == c), ""); 36 static_assert((LCE::modulus == m), ""); 37 /*static_*/assert((LCE::min() == (c == 0u ? 1u: 0u))/*, ""*/); 38 /*static_*/assert((LCE::max() == result_type(m - 1u))/*, ""*/); 39 static_assert((LCE::default_seed == 1), ""); 40} 41 42template <class T> 43void 44test() 45{ 46 test1<T, 0, 0, 0>(); 47 test1<T, 0, 1, 2>(); 48 test1<T, 1, 1, 2>(); 49 const T M(~0); 50 test1<T, 0, 0, M>(); 51 test1<T, 0, M-2, M>(); 52 test1<T, 0, M-1, M>(); 53 test1<T, M-2, 0, M>(); 54 test1<T, M-2, M-2, M>(); 55 test1<T, M-2, M-1, M>(); 56 test1<T, M-1, 0, M>(); 57 test1<T, M-1, M-2, M>(); 58 test1<T, M-1, M-1, M>(); 59} 60 61int main() 62{ 63 test<unsigned short>(); 64 test<unsigned int>(); 65 test<unsigned long>(); 66 test<unsigned long long>(); 67} 68