29.6 Random number generation [rand]
class seed_seq {
public:
using result_type = uint_least32_t;
seed_seq();
template<class T>
seed_seq(initializer_list<T> il);
template<class InputIterator>
seed_seq(InputIterator begin, InputIterator end);
template<class RandomAccessIterator>
void generate(RandomAccessIterator begin, RandomAccessIterator end);
size_t size() const noexcept;
template<class OutputIterator>
void param(OutputIterator dest) const;
seed_seq(const seed_seq& ) = delete;
void operator=(const seed_seq& ) = delete;
private:
vector<result_type> v; };
seed_seq();
Effects: Constructs a
seed_seq object
as if by default-constructing its member
v. template<class T>
seed_seq(initializer_list<T> il);
Requires: T shall be an integer type
. Effects:
Same as
seed_seq(il.begin(), il.end()). template<class InputIterator>
seed_seq(InputIterator begin, InputIterator end);
Requires:
InputIterator shall satisfy the requirements
of an input iterator (Table
90) type
. Moreover,
iterator_traits<InputIterator>::value_type
shall denote an integer type
.Effects: Constructs a
seed_seq object
by the following algorithm:
for( InputIterator s = begin; s != end; ++s)
v.push_back((*s));
template<class RandomAccessIterator>
void generate(RandomAccessIterator begin, RandomAccessIterator end);
Moreover,
iterator_traits<RandomAccessIterator>::value_type
shall denote an unsigned integer type
capable of accommodating 32-bit quantities
. Effects:
Does nothing if
begin == end. Otherwise,
with
and ,
fills the supplied range
according to the following algorithm
in which
each operation is to be carried out modulo ,
each indexing operator applied to begin is to be taken modulo n,
and T(x) is defined as :
- a)
By way of initialization,
set each element of the range to the value
0x8b8b8b8b. Additionally,
for use in subsequent steps,
let
and let ,
where
- b)
With
m as the larger of and
n,
transform the elements of the range:
iteratively for ,
calculate values
and, in order,
increment by ,
increment by ,
and
set begin[k] to .
- c)
Transform the elements of the range again,
beginning where the previous step ended:
iteratively for ,
calculate values
and, in order,
update by xoring it with ,
update by xoring it with ,
and
set begin[k] to .
Throws:
What and when
RandomAccessIterator operations of
begin
and
end throw
. size_t size() const noexcept;
Returns: The number of 32-bit units
that would be returned
by a call to
param(). Complexity: Constant time
. template<class OutputIterator>
void param(OutputIterator dest) const;
Requires:
OutputIterator shall satisfy the requirements
of an output iterator (
[output.iterators])
. Moreover,
the expression
*dest = rt
shall be valid for a value
rt of type
result_type.Effects: Copies the sequence of prepared 32-bit units
to the given destination,
as if by executing the following statement:
copy(v.begin(), v.end(), dest);
Throws:
What and when
OutputIterator operations of
dest throw
.