Implemented some adaptor constructors which I had missed.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@104946 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Howard Hinnant 2010-05-28 15:49:54 +00:00
parent 6bb9f58bc8
commit 3ec31849df
7 changed files with 235 additions and 15 deletions

View File

@ -1834,7 +1834,8 @@ public:
// constructors and seeding functions
explicit linear_congruential_engine(result_type __s = default_seed)
{seed(__s);}
template<class _Sseq> explicit linear_congruential_engine(_Sseq& __q)
template<class _Sseq> explicit linear_congruential_engine(_Sseq& __q,
typename enable_if<!is_convertible<_Sseq, result_type>::value>::type* = 0)
{seed(__q);}
void seed(result_type __s = default_seed)
{seed(integral_constant<bool, __m == 0>(),
@ -2073,7 +2074,8 @@ public:
// constructors and seeding functions
explicit mersenne_twister_engine(result_type __sd = default_seed)
{seed(__sd);}
template<class _Sseq> explicit mersenne_twister_engine(_Sseq& __q)
template<class _Sseq> explicit mersenne_twister_engine(_Sseq& __q,
typename enable_if<!is_convertible<_Sseq, result_type>::value>::type* = 0)
{seed(__q);}
void seed(result_type __sd = default_seed);
template<class _Sseq>
@ -2431,7 +2433,8 @@ public:
// constructors and seeding functions
explicit subtract_with_carry_engine(result_type __sd = default_seed)
{seed(__sd);}
template<class _Sseq> explicit subtract_with_carry_engine(_Sseq& __q)
template<class _Sseq> explicit subtract_with_carry_engine(_Sseq& __q,
typename enable_if<!is_convertible<_Sseq, result_type>::value>::type* = 0)
{seed(__q);}
void seed(result_type __sd = default_seed)
{seed(__sd, integral_constant<unsigned, 1 + (__w - 1) / 32>());}
@ -2680,14 +2683,26 @@ public:
// constructors and seeding functions
discard_block_engine() : __n_(0) {}
// explicit discard_block_engine(const _Engine& __e);
// explicit discard_block_engine(_Engine&& __e);
explicit discard_block_engine(const _Engine& __e)
: __e_(__e), __n_(0) {}
#ifdef _LIBCPP_MOVE
explicit discard_block_engine(_Engine&& __e)
: __e_(_STD::move(__e)), __n_(0) {}
#endif
explicit discard_block_engine(result_type __sd) : __e_(__sd), __n_(0) {}
template<class _Sseq> explicit discard_block_engine(_Sseq& __q)
template<class _Sseq> explicit discard_block_engine(_Sseq& __q,
typename enable_if<!is_convertible<_Sseq, result_type>::value &&
!is_convertible<_Sseq, _Engine>::value>::type* = 0)
: __e_(__q), __n_(0) {}
void seed() {__e_.seed(); __n_ = 0;}
void seed(result_type __sd) {__e_.seed(__sd); __n_ = 0;}
template<class _Sseq> void seed(_Sseq& __q) {__e_.seed(__q); __n_ = 0;}
template<class _Sseq>
typename enable_if
<
!is_convertible<_Sseq, result_type>::value,
void
>::type
seed(_Sseq& __q) {__e_.seed(__q); __n_ = 0;}
// generating functions
result_type operator()();
@ -2855,14 +2870,26 @@ public:
// constructors and seeding functions
independent_bits_engine() {}
// explicit independent_bits_engine(const _Engine& __e);
// explicit independent_bits_engine(_Engine&& __e);
explicit independent_bits_engine(const _Engine& __e)
: __e_(__e) {}
#ifdef _LIBCPP_MOVE
explicit independent_bits_engine(_Engine&& __e)
: __e_(_STD::move(__e)) {}
#endif
explicit independent_bits_engine(result_type __sd) : __e_(__sd) {}
template<class _Sseq> explicit independent_bits_engine(_Sseq& __q)
template<class _Sseq> explicit independent_bits_engine(_Sseq& __q,
typename enable_if<!is_convertible<_Sseq, result_type>::value &&
!is_convertible<_Sseq, _Engine>::value>::type* = 0)
: __e_(__q) {}
void seed() {__e_.seed();}
void seed(result_type __sd) {__e_.seed(__sd);}
template<class _Sseq> void seed(_Sseq& __q) {__e_.seed(__q);}
template<class _Sseq>
typename enable_if
<
!is_convertible<_Sseq, result_type>::value,
void
>::type
seed(_Sseq& __q) {__e_.seed(__q);}
// generating functions
result_type operator()() {return __eval(integral_constant<bool, _R != 0>());}
@ -3051,14 +3078,26 @@ public:
// constructors and seeding functions
shuffle_order_engine() {__init();}
// explicit shuffle_order_engine(const _Engine& __e);
// explicit shuffle_order_engine(_Engine&& e);
explicit shuffle_order_engine(const _Engine& __e)
: __e_(__e) {__init();}
#ifdef _LIBCPP_MOVE
explicit shuffle_order_engine(_Engine&& __e)
: __e_(_STD::move(__e)) {__init();}
#endif
explicit shuffle_order_engine(result_type __sd) : __e_(__sd) {__init();}
template<class _Sseq> explicit shuffle_order_engine(_Sseq& __q)
template<class _Sseq> explicit shuffle_order_engine(_Sseq& __q,
typename enable_if<!is_convertible<_Sseq, result_type>::value &&
!is_convertible<_Sseq, _Engine>::value>::type* = 0)
: __e_(__q) {__init();}
void seed() {__e_.seed(); __init();}
void seed(result_type __sd) {__e_.seed(__sd); __init();}
template<class _Sseq> void seed(_Sseq& __q) {__e_.seed(__q); __init();}
template<class _Sseq>
typename enable_if
<
!is_convertible<_Sseq, result_type>::value,
void
>::type
seed(_Sseq& __q) {__e_.seed(__q); __init();}
// generating functions
result_type operator()() {return __eval(integral_constant<bool, _R != 0>());}

View File

@ -0,0 +1,29 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <random>
// template<class Engine, size_t p, size_t r>
// class discard_block_engine
// explicit discard_block_engine(const Engine& e);
#include <random>
#include <cassert>
int main()
{
{
typedef std::ranlux24_base Engine;
typedef std::ranlux24 Adaptor;
Engine e;
Adaptor a(e);
assert(a.base() == e);
}
}

View File

@ -0,0 +1,30 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <random>
// template<class Engine, size_t p, size_t r>
// class discard_block_engine
// explicit discard_block_engine(const Engine& e);
#include <random>
#include <cassert>
int main()
{
{
typedef std::ranlux24_base Engine;
typedef std::ranlux24 Adaptor;
Engine e;
Engine e0 = e;
Adaptor a(std::move(e0));
assert(a.base() == e);
}
}

View File

@ -0,0 +1,29 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <random>
// template<class Engine, size_t w, class UIntType>
// class independent_bits_engine
// explicit independent_bits_engine(const Engine& e);
#include <random>
#include <cassert>
int main()
{
{
typedef std::mt19937 Engine;
typedef std::independent_bits_engine<Engine, 24, unsigned> Adaptor;
Engine e;
Adaptor a(e);
assert(a.base() == e);
}
}

View File

@ -0,0 +1,30 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <random>
// template<class Engine, size_t w, class UIntType>
// class independent_bits_engine
// explicit independent_bits_engine(const Engine& e);
#include <random>
#include <cassert>
int main()
{
{
typedef std::mt19937 Engine;
typedef std::independent_bits_engine<Engine, 24, unsigned> Adaptor;
Engine e;
Engine e0 = e;
Adaptor a(std::move(e0));
assert(a.base() == e);
}
}

View File

@ -0,0 +1,31 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <random>
// template<class Engine, size_t k>
// class shuffle_order_engine
// explicit shuffle_order_engine(const Engine& e);
#include <random>
#include <cassert>
int main()
{
{
typedef std::minstd_rand0 Engine;
typedef std::knuth_b Adaptor;
Engine e;
Adaptor a(e);
for (unsigned k = 0; k <= Adaptor::table_size; ++k)
e();
assert(a.base() == e);
}
}

View File

@ -0,0 +1,32 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <random>
// template<class Engine, size_t k>
// class shuffle_order_engine
// explicit shuffle_order_engine(const Engine& e);
#include <random>
#include <cassert>
int main()
{
{
typedef std::minstd_rand0 Engine;
typedef std::knuth_b Adaptor;
Engine e;
Engine e0 = e;
Adaptor a(std::move(e0));
for (unsigned k = 0; k <= Adaptor::table_size; ++k)
e();
assert(a.base() == e);
}
}