From e4ec6e1983e27559fdb37d9a458ba0c6b19e3fe8 Mon Sep 17 00:00:00 2001 From: Paolo Carlini Date: Thu, 15 Jun 2006 10:19:06 +0000 Subject: [PATCH] random (class xor_combine): Fix result_type typedef. 2006-06-15 Paolo Carlini * include/tr1/random (class xor_combine): Fix result_type typedef. * testsuite/tr1/5_numerical_facilities/random/xor_combine/ cons/default.cc: New. * testsuite/tr1/5_numerical_facilities/random/xor_combine/ requirements/typedefs.cc: Tweak. * include/tr1/random: Minor cosmetic changes. From-SVN: r114676 --- libstdc++-v3/ChangeLog | 10 ++++ libstdc++-v3/include/tr1/random | 30 ++++++------ .../random/xor_combine/cons/default.cc | 46 +++++++++++++++++++ .../xor_combine/requirements/typedefs.cc | 6 +-- 4 files changed, 76 insertions(+), 16 deletions(-) create mode 100644 libstdc++-v3/testsuite/tr1/5_numerical_facilities/random/xor_combine/cons/default.cc diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 008f1d8b16d..4e299c19976 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,13 @@ +2006-06-15 Paolo Carlini + + * include/tr1/random (class xor_combine): Fix result_type typedef. + * testsuite/tr1/5_numerical_facilities/random/xor_combine/ + cons/default.cc: New. + * testsuite/tr1/5_numerical_facilities/random/xor_combine/ + requirements/typedefs.cc: Tweak. + + * include/tr1/random: Minor cosmetic changes. + 2006-06-14 Ami Tavory Benjamin Kosnik diff --git a/libstdc++-v3/include/tr1/random b/libstdc++-v3/include/tr1/random index 4ecaccaf58a..4973b162b08 100644 --- a/libstdc++-v3/include/tr1/random +++ b/libstdc++-v3/include/tr1/random @@ -825,7 +825,7 @@ _GLIBCXX_BEGIN_NAMESPACE(tr1) class discard_block { // __glibcxx_class_requires(typename base_type::result_type, - // ArithmeticTypeConcept); + // ArithmeticTypeConcept) public: /** The type of the underlying generator engine. */ @@ -991,7 +991,7 @@ _GLIBCXX_BEGIN_NAMESPACE(tr1) * James's luxury-level-3 integer adaptation of Luescher's generator. */ typedef discard_block< - subtract_with_carry, + subtract_with_carry, 223, 24 > ranlux3; @@ -1000,7 +1000,7 @@ _GLIBCXX_BEGIN_NAMESPACE(tr1) * James's luxury-level-4 integer adaptation of Luescher's generator. */ typedef discard_block< - subtract_with_carry, + subtract_with_carry, 389, 24 > ranlux4; @@ -1015,21 +1015,25 @@ _GLIBCXX_BEGIN_NAMESPACE(tr1) class xor_combine { // __glibcxx_class_requires(typename _UniformRandomNumberGenerator1:: - // result_type, ArithmeticTypeConcept); + // result_type, ArithmeticTypeConcept) // __glibcxx_class_requires(typename _UniformRandomNumberGenerator2:: - // result_type, ArithmeticTypeConcept); + // result_type, ArithmeticTypeConcept) public: /** The type of the the first underlying generator engine. */ - typedef _UniformRandomNumberGenerator1 base1_type; + typedef _UniformRandomNumberGenerator1 base1_type; /** The type of the the second underlying generator engine. */ - typedef _UniformRandomNumberGenerator2 base2_type; + typedef _UniformRandomNumberGenerator2 base2_type; + + private: + typedef typename base1_type::result_type _Result_type1; + typedef typename base2_type::result_type _Result_type2; + + public: /** The type of the generated random value. */ typedef typename _Private::_Select< - (sizeof(base1_type) > sizeof(base2_type)), - base1_type, - base2_type - >::_Type result_type; + (sizeof(_Result_type1) > sizeof(_Result_type2)), + _Result_type1, _Result_type2>::_Type result_type; // parameter values static const int shift1 = __s1; @@ -1185,7 +1189,7 @@ _GLIBCXX_BEGIN_NAMESPACE(tr1) #else explicit - random_device(const std::string& __token = "rand") + random_device(const std::string& __token = "mt19937") : _M_mt(_M_strtoul(__token)) { } private: @@ -1193,7 +1197,7 @@ _GLIBCXX_BEGIN_NAMESPACE(tr1) _M_strtoul(const std::string& __str) { unsigned long __ret = 5489UL; - if (__str != "rand") + if (__str != "mt19937") { const char* __nptr = __str.c_str(); char* __endptr; diff --git a/libstdc++-v3/testsuite/tr1/5_numerical_facilities/random/xor_combine/cons/default.cc b/libstdc++-v3/testsuite/tr1/5_numerical_facilities/random/xor_combine/cons/default.cc new file mode 100644 index 00000000000..5ac01b8dd81 --- /dev/null +++ b/libstdc++-v3/testsuite/tr1/5_numerical_facilities/random/xor_combine/cons/default.cc @@ -0,0 +1,46 @@ +// 2006-06-15 Paolo Carlini +// +// Copyright (C) 2006 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +// 5.1.4.6 Class template xor_combine [tr.rand.eng.xor] +// 5.1.1 Table 15 default ctor + +#include +#include + +void +test01() +{ + bool test __attribute__((unused)) = true; + + using namespace std::tr1; + xor_combine + < + minstd_rand, 1, + minstd_rand0, 2 + > x; + + VERIFY( x() == 32642 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/tr1/5_numerical_facilities/random/xor_combine/requirements/typedefs.cc b/libstdc++-v3/testsuite/tr1/5_numerical_facilities/random/xor_combine/requirements/typedefs.cc index 0665f8ef43c..bd140b988aa 100644 --- a/libstdc++-v3/testsuite/tr1/5_numerical_facilities/random/xor_combine/requirements/typedefs.cc +++ b/libstdc++-v3/testsuite/tr1/5_numerical_facilities/random/xor_combine/requirements/typedefs.cc @@ -32,9 +32,9 @@ test01() typedef xor_combine < - subtract_with_carry, 1, - linear_congruential, 2 + minstd_rand, 1, + mt19937, 2 > test_type; - + typedef test_type::result_type result_type; }