From: Paolo Carlini Date: Mon, 12 Oct 2009 19:11:31 +0000 (+0000) Subject: random.h (class linear_congruential_engine, [...]): Do not use simulated concept... X-Git-Tag: releases/gcc-4.5.0~2953 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=77e3c51603665bfe186b8b615500f6a22d8ff77f;p=thirdparty%2Fgcc.git random.h (class linear_congruential_engine, [...]): Do not use simulated concept checks... 2009-10-12 Paolo Carlini * include/bits/random.h (class linear_congruential_engine, class mersenne_twister_engine, class subtract_with_carry_engine, class discard_block_engine, class independent_bits_engine, class shuffle_order_engine, class uniform_int_distribution, class binomial_distribution, class geometric_distribution, class negative_binomial_distribution, class poisson_distribution, class discrete_distribution): Do not use simulated concept checks, tidy startic_asserts on argument types and ranges. (class uniform_real_distribution, class normal_distribution, class lognormal_distribution, class gamma_distribution, class chi_squared_distribution, class cauchy_distribution, class fisher_f_distribution, class student_t_distribution, class exponential_distribution, class weibull_distribution, class extreme_value_distribution, class piecewise_linear_distribution, class piecewise_constant_distribution): Add static_assert on template argument type. * include/std/random: Do not include . * testsuite/26_numerics/random/discard_block_engine/cons/base_move.cc: Fix. * testsuite/26_numerics/random/discard_block_engine/cons/seed1.cc: Likewise. * testsuite/26_numerics/random/discard_block_engine/cons/seed2.cc: Likewise. * testsuite/26_numerics/random/discard_block_engine/cons/base_copy.cc: Likewise. * testsuite/26_numerics/random/discard_block_engine/cons/default.cc: Likewise. * testsuite/26_numerics/random/discard_block_engine/cons/seed_seq.cc: Likewise. * testsuite/26_numerics/random/discard_block_engine/requirements/ typedefs.cc: Likewise. * testsuite/26_numerics/random/discard_block_engine/operators/ equal.cc: Likewise. * testsuite/26_numerics/random/discard_block_engine/operators/ serialize.cc: Likewise. * testsuite/26_numerics/random/linear_congruential_engine/ requirements/non_uint_neg.cc: Tweak. From-SVN: r152682 --- diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index e68d69d86bb8..2143533f6039 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,43 @@ +2009-10-12 Paolo Carlini + + * include/bits/random.h (class linear_congruential_engine, + class mersenne_twister_engine, class subtract_with_carry_engine, + class discard_block_engine, class independent_bits_engine, + class shuffle_order_engine, class uniform_int_distribution, + class binomial_distribution, class geometric_distribution, + class negative_binomial_distribution, class poisson_distribution, + class discrete_distribution): Do not use simulated concept checks, + tidy startic_asserts on argument types and ranges. + (class uniform_real_distribution, class normal_distribution, + class lognormal_distribution, class gamma_distribution, + class chi_squared_distribution, class cauchy_distribution, + class fisher_f_distribution, class student_t_distribution, + class exponential_distribution, class weibull_distribution, + class extreme_value_distribution, class piecewise_linear_distribution, + class piecewise_constant_distribution): Add static_assert on + template argument type. + * include/std/random: Do not include . + * testsuite/26_numerics/random/discard_block_engine/cons/base_move.cc: + Fix. + * testsuite/26_numerics/random/discard_block_engine/cons/seed1.cc: + Likewise. + * testsuite/26_numerics/random/discard_block_engine/cons/seed2.cc: + Likewise. + * testsuite/26_numerics/random/discard_block_engine/cons/base_copy.cc: + Likewise. + * testsuite/26_numerics/random/discard_block_engine/cons/default.cc: + Likewise. + * testsuite/26_numerics/random/discard_block_engine/cons/seed_seq.cc: + Likewise. + * testsuite/26_numerics/random/discard_block_engine/requirements/ + typedefs.cc: Likewise. + * testsuite/26_numerics/random/discard_block_engine/operators/ + equal.cc: Likewise. + * testsuite/26_numerics/random/discard_block_engine/operators/ + serialize.cc: Likewise. + * testsuite/26_numerics/random/linear_congruential_engine/ + requirements/non_uint_neg.cc: Tweak. + 2009-10-10 Gerald Pfeifer * doc/xml/manual/messages.xml: Update GNU gettext reference. diff --git a/libstdc++-v3/include/bits/random.h b/libstdc++-v3/include/bits/random.h index 06aa6f87b916..2c2c79ca16b1 100644 --- a/libstdc++-v3/include/bits/random.h +++ b/libstdc++-v3/include/bits/random.h @@ -32,7 +32,6 @@ namespace std { - // [26.4] Random number generation /** @@ -154,10 +153,10 @@ namespace std template class linear_congruential_engine { - __glibcxx_class_requires(_UIntType, _UnsignedIntegerConcept) - static_assert(__m == 0 || (__a < __m && __c < __m), - "template arguments out of bounds" - " in linear_congruential_engine"); + static_assert(std::is_unsigned<_UIntType>::value, "template argument " + "_UIntType not an unsigned integral type"); + static_assert(__m == 0u || (__a < __m && __c < __m), + "template argument __m out of bounds"); public: /** The type of the generated random value. */ @@ -341,35 +340,27 @@ namespace std _UIntType __c, size_t __l, _UIntType __f> class mersenne_twister_engine { - __glibcxx_class_requires(_UIntType, _UnsignedIntegerConcept) - - static_assert(__m >= 1U, - "mersenne_twister_engine template arguments out of bounds"); - static_assert(__n >= __m, - "mersenne_twister_engine template arguments out of bounds"); - static_assert(__w >= __r, - "mersenne_twister_engine template arguments out of bounds"); - static_assert(__w >= __u, - "mersenne_twister_engine template arguments out of bounds"); - static_assert(__w >= __s, - "mersenne_twister_engine template arguments out of bounds"); - static_assert(__w >= __t, - "mersenne_twister_engine template arguments out of bounds"); - static_assert(__w >= __l, - "mersenne_twister_engine template arguments out of bounds"); - static_assert(__w <= - static_cast(std::numeric_limits<_UIntType>::digits), - "mersenne_twister_engine template arguments out of bounds"); + static_assert(std::is_unsigned<_UIntType>::value, "template argument " + "_UIntType not an unsigned integral type"); + static_assert(1u <= __m && __m <= __n, + "template argument __m out of bounds"); + static_assert(__r <= __w, "template argument __r out of bound"); + static_assert(__u <= __w, "template argument __u out of bound"); + static_assert(__s <= __w, "template argument __s out of bound"); + static_assert(__t <= __w, "template argument __t out of bound"); + static_assert(__l <= __w, "template argument __l out of bound"); + static_assert(__w <= std::numeric_limits<_UIntType>::digits, + "template argument __w out of bound"); static_assert(__a <= (__detail::_Shift<_UIntType, __w>::__value - 1), - "mersenne_twister_engine template arguments out of bounds"); + "template argument __a out of bound"); static_assert(__b <= (__detail::_Shift<_UIntType, __w>::__value - 1), - "mersenne_twister_engine template arguments out of bounds"); + "template argument __b out of bound"); static_assert(__c <= (__detail::_Shift<_UIntType, __w>::__value - 1), - "mersenne_twister_engine template arguments out of bounds"); + "template argument __c out of bound"); static_assert(__d <= (__detail::_Shift<_UIntType, __w>::__value - 1), - "mersenne_twister_engine template arguments out of bounds"); + "template argument __d out of bound"); static_assert(__f <= (__detail::_Shift<_UIntType, __w>::__value - 1), - "mersenne_twister_engine template arguments out of bounds"); + "template argument __f out of bound"); public: /** The type of the generated random value. */ @@ -538,13 +529,12 @@ namespace std template class subtract_with_carry_engine { - __glibcxx_class_requires(_UIntType, _UnsignedIntegerConcept) - static_assert(__s > 0U && __r > __s - && __w > 0U - && __w <= static_cast - (std::numeric_limits<_UIntType>::digits), - "template arguments out of bounds" - " in subtract_with_carry_engine"); + static_assert(std::is_unsigned<_UIntType>::value, "template argument " + "_UIntType not an unsigned integral type"); + static_assert(0u < __s && __s < __r, + "template argument __s out of bounds"); + static_assert(0u < __w && __w <= std::numeric_limits<_UIntType>::digits, + "template argument __w out of bounds"); public: /** The type of the generated random value. */ @@ -702,9 +692,8 @@ namespace std template class discard_block_engine { - static_assert(__r >= 1U && __p >= __r, - "template arguments out of bounds" - " in discard_block_engine"); + static_assert(1 <= __r && __r <= __p, + "template argument __r out of bounds"); public: /** The type of the generated random value. */ @@ -903,12 +892,10 @@ namespace std template class independent_bits_engine { - static_assert(__w > 0U - && __w <= - static_cast - (std::numeric_limits<_UIntType>::digits), - "template arguments out of bounds " - "in independent_bits_engine"); + static_assert(std::is_unsigned<_UIntType>::value, "template argument " + "_UIntType not an unsigned integral type"); + static_assert(0u < __w && __w <= std::numeric_limits<_UIntType>::digits, + "template argument __w out of bounds"); public: /** The type of the generated random value. */ @@ -1102,9 +1089,7 @@ namespace std template class shuffle_order_engine { - static_assert(__k >= 1U, - "template arguments out of bounds" - " in shuffle_order_engine"); + static_assert(1u <= __k, "template argument __k out of bound"); public: /** The type of the generated random value. */ @@ -1480,7 +1465,8 @@ namespace std template class uniform_int_distribution { - __glibcxx_class_requires(_IntType, _IntegerConcept) + static_assert(std::is_integral<_IntType>::value, + "template argument not an integral type"); public: /** The type of the range of the distribution. */ @@ -1633,6 +1619,9 @@ namespace std template class uniform_real_distribution { + static_assert(std::is_floating_point<_RealType>::value, + "template argument not a floating point type"); + public: /** The type of the range of the distribution. */ typedef _RealType result_type; @@ -1791,6 +1780,9 @@ namespace std template class normal_distribution { + static_assert(std::is_floating_point<_RealType>::value, + "template argument not a floating point type"); + public: /** The type of the range of the distribution. */ typedef _RealType result_type; @@ -1943,6 +1935,9 @@ namespace std template class lognormal_distribution { + static_assert(std::is_floating_point<_RealType>::value, + "template argument not a floating point type"); + public: /** The type of the range of the distribution. */ typedef _RealType result_type; @@ -2086,6 +2081,9 @@ namespace std template class gamma_distribution { + static_assert(std::is_floating_point<_RealType>::value, + "template argument not a floating point type"); + public: /** The type of the range of the distribution. */ typedef _RealType result_type; @@ -2243,6 +2241,9 @@ namespace std template class chi_squared_distribution { + static_assert(std::is_floating_point<_RealType>::value, + "template argument not a floating point type"); + public: /** The type of the range of the distribution. */ typedef _RealType result_type; @@ -2378,6 +2379,9 @@ namespace std template class cauchy_distribution { + static_assert(std::is_floating_point<_RealType>::value, + "template argument not a floating point type"); + public: /** The type of the range of the distribution. */ typedef _RealType result_type; @@ -2519,6 +2523,9 @@ namespace std template class fisher_f_distribution { + static_assert(std::is_floating_point<_RealType>::value, + "template argument not a floating point type"); + public: /** The type of the range of the distribution. */ typedef _RealType result_type; @@ -2670,6 +2677,9 @@ namespace std template class student_t_distribution { + static_assert(std::is_floating_point<_RealType>::value, + "template argument not a floating point type"); + public: /** The type of the range of the distribution. */ typedef _RealType result_type; @@ -2972,7 +2982,8 @@ namespace std template class binomial_distribution { - __glibcxx_class_requires(_IntType, _IntegerConcept) + static_assert(std::is_integral<_IntType>::value, + "template argument not an integral type"); public: /** The type of the range of the distribution. */ @@ -3142,7 +3153,8 @@ namespace std template class geometric_distribution { - __glibcxx_class_requires(_IntType, _IntegerConcept) + static_assert(std::is_integral<_IntType>::value, + "template argument not an integral type"); public: /** The type of the range of the distribution. */ @@ -3287,7 +3299,8 @@ namespace std template class negative_binomial_distribution { - __glibcxx_class_requires(_IntType, _IntegerConcept) + static_assert(std::is_integral<_IntType>::value, + "template argument not an integral type"); public: /** The type of the range of the distribution. */ @@ -3439,7 +3452,8 @@ namespace std template class poisson_distribution { - __glibcxx_class_requires(_IntType, _IntegerConcept) + static_assert(std::is_integral<_IntType>::value, + "template argument not an integral type"); public: /** The type of the range of the distribution. */ @@ -3594,6 +3608,9 @@ namespace std template class exponential_distribution { + static_assert(std::is_floating_point<_RealType>::value, + "template argument not a floating point type"); + public: /** The type of the range of the distribution. */ typedef _RealType result_type; @@ -3736,6 +3753,9 @@ namespace std template class weibull_distribution { + static_assert(std::is_floating_point<_RealType>::value, + "template argument not a floating point type"); + public: /** The type of the range of the distribution. */ typedef _RealType result_type; @@ -3879,6 +3899,9 @@ namespace std template class extreme_value_distribution { + static_assert(std::is_floating_point<_RealType>::value, + "template argument not a floating point type"); + public: /** The type of the range of the distribution. */ typedef _RealType result_type; @@ -4021,7 +4044,8 @@ namespace std template class discrete_distribution { - __glibcxx_class_requires(_IntType, _IntegerConcept) + static_assert(std::is_integral<_IntType>::value, + "template argument not an integral type"); public: /** The type of the range of the distribution. */ @@ -4185,6 +4209,9 @@ namespace std template class piecewise_constant_distribution { + static_assert(std::is_floating_point<_RealType>::value, + "template argument not a floating point type"); + public: /** The type of the range of the distribution. */ typedef _RealType result_type; @@ -4363,6 +4390,9 @@ namespace std template class piecewise_linear_distribution { + static_assert(std::is_floating_point<_RealType>::value, + "template argument not a floating point type"); + public: /** The type of the range of the distribution. */ typedef _RealType result_type; diff --git a/libstdc++-v3/include/std/random b/libstdc++-v3/include/std/random index b57ef4925d62..72d3ceb7f431 100644 --- a/libstdc++-v3/include/std/random +++ b/libstdc++-v3/include/std/random @@ -43,7 +43,6 @@ #include #include #include -#include #include #include diff --git a/libstdc++-v3/testsuite/26_numerics/random/discard_block_engine/cons/base_copy.cc b/libstdc++-v3/testsuite/26_numerics/random/discard_block_engine/cons/base_copy.cc index 328dd71d0bb2..6c8498e7b106 100644 --- a/libstdc++-v3/testsuite/26_numerics/random/discard_block_engine/cons/base_copy.cc +++ b/libstdc++-v3/testsuite/26_numerics/random/discard_block_engine/cons/base_copy.cc @@ -31,7 +31,7 @@ test01() { bool test __attribute__((unused)) = true; - typedef std::subtract_with_carry_engine + typedef std::subtract_with_carry_engine base_engine; base_engine b; diff --git a/libstdc++-v3/testsuite/26_numerics/random/discard_block_engine/cons/base_move.cc b/libstdc++-v3/testsuite/26_numerics/random/discard_block_engine/cons/base_move.cc index 990dc9b3fe9b..fabe17a2b563 100644 --- a/libstdc++-v3/testsuite/26_numerics/random/discard_block_engine/cons/base_move.cc +++ b/libstdc++-v3/testsuite/26_numerics/random/discard_block_engine/cons/base_move.cc @@ -31,7 +31,7 @@ test01() { bool test __attribute__((unused)) = true; - typedef std::subtract_with_carry_engine + typedef std::subtract_with_carry_engine base_engine; std::discard_block_engine diff --git a/libstdc++-v3/testsuite/26_numerics/random/discard_block_engine/cons/default.cc b/libstdc++-v3/testsuite/26_numerics/random/discard_block_engine/cons/default.cc index 17fea5bdb479..926bb2c24dbe 100644 --- a/libstdc++-v3/testsuite/26_numerics/random/discard_block_engine/cons/default.cc +++ b/libstdc++-v3/testsuite/26_numerics/random/discard_block_engine/cons/default.cc @@ -33,7 +33,7 @@ test01() std::discard_block_engine < - std::subtract_with_carry_engine, + std::subtract_with_carry_engine, 389, 24 > e; } diff --git a/libstdc++-v3/testsuite/26_numerics/random/discard_block_engine/cons/seed1.cc b/libstdc++-v3/testsuite/26_numerics/random/discard_block_engine/cons/seed1.cc index efe194c99f0c..4cedeb85d399 100644 --- a/libstdc++-v3/testsuite/26_numerics/random/discard_block_engine/cons/seed1.cc +++ b/libstdc++-v3/testsuite/26_numerics/random/discard_block_engine/cons/seed1.cc @@ -35,7 +35,7 @@ test01() std::discard_block_engine < - std::subtract_with_carry_engine, + std::subtract_with_carry_engine, 389, 24 > e(seed); } diff --git a/libstdc++-v3/testsuite/26_numerics/random/discard_block_engine/cons/seed2.cc b/libstdc++-v3/testsuite/26_numerics/random/discard_block_engine/cons/seed2.cc index 82f6fdb1c74a..b66752c2b6e6 100644 --- a/libstdc++-v3/testsuite/26_numerics/random/discard_block_engine/cons/seed2.cc +++ b/libstdc++-v3/testsuite/26_numerics/random/discard_block_engine/cons/seed2.cc @@ -35,7 +35,7 @@ test01() std::discard_block_engine < - std::subtract_with_carry_engine, + std::subtract_with_carry_engine, 389, 24 > e(seed); } diff --git a/libstdc++-v3/testsuite/26_numerics/random/discard_block_engine/cons/seed_seq.cc b/libstdc++-v3/testsuite/26_numerics/random/discard_block_engine/cons/seed_seq.cc index 58f0f1c392a3..aa86b9afedc9 100644 --- a/libstdc++-v3/testsuite/26_numerics/random/discard_block_engine/cons/seed_seq.cc +++ b/libstdc++-v3/testsuite/26_numerics/random/discard_block_engine/cons/seed_seq.cc @@ -35,7 +35,7 @@ test01() std::discard_block_engine < - std::subtract_with_carry_engine, + std::subtract_with_carry_engine, 389, 24 > e(seq); } diff --git a/libstdc++-v3/testsuite/26_numerics/random/discard_block_engine/operators/equal.cc b/libstdc++-v3/testsuite/26_numerics/random/discard_block_engine/operators/equal.cc index db2497540a37..5d63114fef3b 100644 --- a/libstdc++-v3/testsuite/26_numerics/random/discard_block_engine/operators/equal.cc +++ b/libstdc++-v3/testsuite/26_numerics/random/discard_block_engine/operators/equal.cc @@ -33,7 +33,7 @@ test01() std::discard_block_engine < - std::subtract_with_carry_engine, + std::subtract_with_carry_engine, 389, 24 > u, v; diff --git a/libstdc++-v3/testsuite/26_numerics/random/discard_block_engine/operators/serialize.cc b/libstdc++-v3/testsuite/26_numerics/random/discard_block_engine/operators/serialize.cc index 1d39a213f47c..7aec649c03b9 100644 --- a/libstdc++-v3/testsuite/26_numerics/random/discard_block_engine/operators/serialize.cc +++ b/libstdc++-v3/testsuite/26_numerics/random/discard_block_engine/operators/serialize.cc @@ -35,7 +35,7 @@ test01() std::stringstream str; std::discard_block_engine < - std::subtract_with_carry_engine, + std::subtract_with_carry_engine, 389, 24 > u, v; diff --git a/libstdc++-v3/testsuite/26_numerics/random/discard_block_engine/requirements/typedefs.cc b/libstdc++-v3/testsuite/26_numerics/random/discard_block_engine/requirements/typedefs.cc index 379b3aeb9782..6e23316caa1d 100644 --- a/libstdc++-v3/testsuite/26_numerics/random/discard_block_engine/requirements/typedefs.cc +++ b/libstdc++-v3/testsuite/26_numerics/random/discard_block_engine/requirements/typedefs.cc @@ -31,7 +31,7 @@ test01() { typedef std::discard_block_engine < - std::subtract_with_carry_engine, + std::subtract_with_carry_engine, 389, 24 > test_type; diff --git a/libstdc++-v3/testsuite/26_numerics/random/linear_congruential_engine/requirements/non_uint_neg.cc b/libstdc++-v3/testsuite/26_numerics/random/linear_congruential_engine/requirements/non_uint_neg.cc index f54d76ada07a..18fb44fdac54 100644 --- a/libstdc++-v3/testsuite/26_numerics/random/linear_congruential_engine/requirements/non_uint_neg.cc +++ b/libstdc++-v3/testsuite/26_numerics/random/linear_congruential_engine/requirements/non_uint_neg.cc @@ -19,7 +19,7 @@ // . // { dg-do compile } -// { dg-options "-std=c++0x -D_GLIBCXX_CONCEPT_CHECKS" } +// { dg-options "-std=c++0x" } // { dg-require-cstdint "" } // { dg-error "not a valid type" "" { target *-*-* } 32 } // { dg-error "invalid type" "" { target *-*-* } 32 }