diff options
author | Paolo Carlini <pcarlini@suse.de> | 2006-06-15 10:19:06 +0000 |
---|---|---|
committer | Paolo Carlini <paolo@gcc.gnu.org> | 2006-06-15 10:19:06 +0000 |
commit | e4ec6e1983e27559fdb37d9a458ba0c6b19e3fe8 (patch) | |
tree | 717ee4fccb4a123e2439029ce4a5ceea20ef0b78 /libstdc++-v3 | |
parent | 4f6c9110755b4f300c0027433cd2ff466f9a70c4 (diff) | |
download | gcc-e4ec6e1983e27559fdb37d9a458ba0c6b19e3fe8.zip gcc-e4ec6e1983e27559fdb37d9a458ba0c6b19e3fe8.tar.gz gcc-e4ec6e1983e27559fdb37d9a458ba0c6b19e3fe8.tar.bz2 |
random (class xor_combine): Fix result_type typedef.
2006-06-15 Paolo Carlini <pcarlini@suse.de>
* 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
Diffstat (limited to 'libstdc++-v3')
4 files changed, 76 insertions, 16 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 008f1d8..4e299c1 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,13 @@ +2006-06-15 Paolo Carlini <pcarlini@suse.de> + + * 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 <atavory@gmail.com> Benjamin Kosnik <bkoz@redhat.com> diff --git a/libstdc++-v3/include/tr1/random b/libstdc++-v3/include/tr1/random index 4ecacca..4973b16 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<int, (1<<24), 10, 24>, + subtract_with_carry<int, (1 << 24), 10, 24>, 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<int, (1<<24), 10, 24>, + subtract_with_carry<int, (1 << 24), 10, 24>, 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 0000000..5ac01b8 --- /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 <pcarlini@suse.de> +// +// 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 <tr1/random> +#include <testsuite_hooks.h> + +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 0665f8e..bd140b9 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<long, (1 << 24), 10, 24>, 1, - linear_congruential<unsigned long, 16807, 0, 2147483647>, 2 + minstd_rand, 1, + mt19937, 2 > test_type; - + typedef test_type::result_type result_type; } |