[rand.util.seedseq] (original) (raw)

26 Numerics library [numerics]

26.6 Random number generation [rand]

26.6.7 Utilities [rand.util]

26.6.7.1 Class seed_­seq [rand.util.seedseq]

class seed_seq { public:

using result_type = uint_least32_t;

seed_seq(); template seed_seq(initializer_list il); template seed_seq(InputIterator begin, InputIterator end);

template void generate(RandomAccessIterator begin, RandomAccessIterator end);

size_t size() const noexcept; template void param(OutputIterator dest) const;

seed_seq(const seed_seq&) = delete; void operator=(const seed_seq&) = delete;

private: vector v;
};

Postconditions: v.empty() is true.

template<class T> seed_seq(initializer_list<T> il);

Mandates: T is an integer type.

Effects: Same as seed_­seq(il.begin(), il.end()).

template<class InputIterator> seed_seq(InputIterator begin, InputIterator end);

Mandates: iterator_­traits<InputIterator>​::​value_­type is an integer type.

Preconditions: InputIterator meets theCpp17InputIterator requirements ([input.iterators]).

Effects:Initializes vby the following algorithm:

for (InputIterator s = begin; s != end; ++s) v.push_back((*s));

template<class RandomAccessIterator> void generate(RandomAccessIterator begin, RandomAccessIterator end);

Mandates: iterator_­traits<RandomAccessIterator>​::​​value_­type is an unsigned integer type capable of accommodating 32-bit quantities.

Preconditions: RandomAccessIterator meets theCpp17RandomAccessIterator requirements ([random.access.iterators]) and the requirements of a mutable iterator.

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 :

Throws:What and when RandomAccessIterator operations of beginand 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;

Preconditions: OutputIterator meets theCpp17OutputIterator requirements ([output.iterators]).

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.