Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions stl/inc/random
Original file line number Diff line number Diff line change
Expand Up @@ -1349,7 +1349,10 @@ public:
template <class _Engine, int _Px, int _Rx>
class discard_block { // discard_block compound engine
public:
using base_type = _Engine;
#if _HAS_TR1_NAMESPACE
using base_type _DEPRECATE_TR1_NAMESPACE = _Engine; // TR1-only typedef
#endif // _HAS_TR1_NAMESPACE

using result_type = typename _Engine::result_type;

static constexpr int block_size = _Px;
Expand All @@ -1359,6 +1362,8 @@ public:

explicit discard_block(const _Engine& _Ex) : _Eng(_Ex), _Nx(0) {}

explicit discard_block(_Engine&& _Ex) : _Eng(_STD move(_Ex)), _Nx(0) {}

explicit discard_block(result_type _Seed) : _Eng(_Seed), _Nx(0) {}

template <class _Seed_seq, _Enable_if_seed_seq_t<_Seed_seq, discard_block, _Engine> = 0>
Expand All @@ -1380,7 +1385,7 @@ public:
_Nx = 0;
}

_NODISCARD const base_type& base() const noexcept {
_NODISCARD const _Engine& base() const noexcept {
return _Eng;
}

Expand Down Expand Up @@ -1433,20 +1438,21 @@ public:
}

private:
base_type _Eng;
_Engine _Eng;
int _Nx;
};

template <class _Engine, size_t _Px, size_t _Rx>
class _Discard_block_base { // TRANSITION, ABI, should be merged into discard_block_engine
public:
using base_type = _Engine;
using result_type = typename _Engine::result_type;

_Discard_block_base() : _Eng(), _Nx(0) {}

explicit _Discard_block_base(const _Engine& _Ex) : _Eng(_Ex), _Nx(0) {}

explicit _Discard_block_base(_Engine&& _Ex) : _Eng(_STD move(_Ex)), _Nx(0) {}

explicit _Discard_block_base(result_type _Seed) : _Eng(_Seed), _Nx(0) {}

template <class _Seed_seq, _Enable_if_seed_seq_t<_Seed_seq, _Discard_block_base, _Engine> = 0>
Expand All @@ -1468,7 +1474,7 @@ public:
_Nx = 0;
}

_NODISCARD const base_type& base() const noexcept {
_NODISCARD const _Engine& base() const noexcept {
return _Eng;
}

Expand Down Expand Up @@ -1513,7 +1519,7 @@ public:
}

private:
base_type _Eng;
_Engine _Eng;
size_t _Nx;
};

Expand Down Expand Up @@ -1559,7 +1565,6 @@ public:
static_assert(
0 < _Wx && _Wx <= numeric_limits<_UIntType>::digits, "invalid template argument for independent_bits_engine");

using base_type = _Engine;
using result_type = _UIntType;
using _Eres = typename _Engine::result_type;

Expand Down Expand Up @@ -1707,7 +1712,6 @@ class shuffle_order_engine { // shuffle_order_engine compound engine
public:
static_assert(0 < _Kx, "invalid template argument for shuffle_order_engine");

using base_type = _Engine;
using result_type = typename _Engine::result_type;

static constexpr size_t table_size = _Kx;
Expand Down
2 changes: 2 additions & 0 deletions tests/tr1/tests/random1/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -466,9 +466,11 @@ static void tdiscard() {
typedef STD discard_block<rng_base_t, 223, 24> rng_t;
CHECK_INT(rng_t::block_size, 223);
CHECK_INT(rng_t::used_block, 24);
#if _HAS_TR1_NAMESPACE
CHECK_INT(rng_t::base_type::modulus, 1 << 24);
CHECK_INT(rng_t::base_type::long_lag, 24);
CHECK_INT(rng_t::base_type::short_lag, 10);
#endif // _HAS_TR1_NAMESPACE
bool st = STD is_same<rng_t::result_type, Uint32>::value;
CHECK(st);

Expand Down