public member function
<random>

std::discard_block_engine::seed

(1)
void seed();
(2)
void seed (result_type val);
(3)
template <class Sseq>void seed (Sseq& q);
Seed base engine
Re-initializes the state of the base engine, by calling its seed member function with the same argument (if any).

Parameters

val
A seeding value. This value is passed to the base engine's constructor.
result_type is a member type, defined as an alias of the type of elements produced by base.
q
A seed sequence object, such as an object of type seed_seq.
Sseq shall be a seed sequence class, with a generate member function.

Return value

None

Example

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
// discard_block_engine::seed example
#include <iostream>
#include <chrono>
#include <random>

int main ()
{
  typedef std::chrono::high_resolution_clock myclock;
  myclock::time_point beginning = myclock::now();

  // obtain a seed from a user string:
  std::string str;
  std::cout << "Please, enter a seed: ";
  std::getline(std::cin,str);
  std::seed_seq seed1 (str.begin(),str.end());

  // obtain a seed from the timer
  myclock::duration d = myclock::now() - beginning;
  unsigned seed2 = d.count();

  // ranlux24 is a standard instantitation of discard_block_engine:
  std::ranlux24 generator (seed1);
  std::cout << "Your seed produced: " << generator() << std::endl;

  generator.seed (seed2);
  std::cout << "A time seed produced: " << generator() << std::endl;

  return 0;
}

Possible output:
Please, enter a seed: Cooper
Your seed produced: 14845138
A time seed produced: 12807810


Complexity

Determined by the base engine.

See also