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
This commit is contained in:
Paolo Carlini 2006-06-15 10:19:06 +00:00 committed by Paolo Carlini
parent 4f6c911075
commit e4ec6e1983
4 changed files with 76 additions and 16 deletions

View File

@ -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>

View File

@ -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;

View File

@ -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;
}

View File

@ -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;
}