#
A
discard_
block_
engine
random number engine adaptor produces random numbers selected from those produced by some base engine
e
.
The state
x
i
of a
discard_
block_
engine
engine adaptor object
x
consists of the state
e
i
of its base engine
e
and an additional integer
n
.
The size of the state is the size of
e
's state plus
1
.
2
#
The transition algorithm discards all but
r
>
0
values from each block of
p
≥
r
values delivered by
e
.
The state transition is performed as follows: If
n
≥
r
, advance the state of
e
from
e
i
to
e
i
+
p
−
r
and set
n
to
0
.
In any case, then increment
n
and advance
e
's then-current state
e
j
to
e
j
+
1
.
3
#
The generation algorithm yields the value returned by the last invocation of
e
(
)
while advancing
e
's state as described above
.
🔗
namespace
std
{
template
<
class
Engine, size_t p, size_t r
>
class
discard_block_engine
{
public
:
/ types
using
result_type
=
Engine
::
result_type;
/ engine characteristics
static
constexpr
size_t block_size
=
p;
static
constexpr
size_t used_block
=
r;
static
constexpr
result_type min
(
)
{
return
Engine
::
min
(
)
;
}
static
constexpr
result_type max
(
)
{
return
Engine
::
max
(
)
;
}
/ constructors and seeding functions
discard_block_engine
(
)
;
explicit
discard_block_engine
(
const
Engine
&
e
)
;
explicit
discard_block_engine
(
Engine
&
&
e
)
;
explicit
discard_block_engine
(
result_type s
)
;
template
<
class
Sseq
>
explicit
discard_block_engine
(
Sseq
&
q
)
;
void
seed
(
)
;
void
seed
(
result_type s
)
;
template
<
class
Sseq
>
void
seed
(
Sseq
&
q
)
;
/ equality operators
friend
bool
operator
=
(
const
discard_block_engine
&
x,
const
discard_block_engine
&
y
)
;
/ generating functions
result_type
operator
(
)
(
)
;
void
discard
(
unsigned
long
z
)
;
/ property functions
const
Engine
&
base
(
)
const
noexcept
{
return
e;
}
/ inserters and extractors
template
<
class
charT,
class
traits
>
friend
basic_ostream
<
charT, traits
>
&
operator
<
(
basic_ostream
<
charT, traits
>
&
os,
const
discard_block_engine
&
x
)
;
/ hosted
template
<
class
charT,
class
traits
>
friend
basic_istream
<
charT, traits
>
&
operator
>
(
basic_istream
<
charT, traits
>
&
is, discard_block_engine
&
x
)
;
/ hosted
private
:
Engine e;
/
exposition only
size_t n;
/
exposition only
}
;
}
4
#
The following relations shall hold:
0
<
r
and
r
<
=
p
.
5
#
The textual representation consists of the textual representation of
e
followed by the value of
n
.
6
#
In addition to its behavior pursuant to subclause
[rand.
req.
adapt]
, each constructor
that is not a copy constructor sets
n
to
0
.