A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://cplusplus.com/reference/random/discard_block_engine/discard_block_engine/ below:

public member function

<random>

std::discard_block_engine::discard_block_engine (1)
discard_block_engine();
(2)
explicit discard_block_engine (const Engine& e);
(3)
explicit discard_block_engine (Engine&& e);
(4)
explicit discard_block_engine (result_type val);
(5)
template <class Sseq>explicit discard_block_engine (Sseq& q);

Construct discard-block engine

Constructs a discard_block_engine object, by initializing its internal base engine to e or to an engine constructed with argument val or q (or default-constructed).

The internal counter is set to 0.



Parameters
e
An engine object, whose state is either copied to or moved as the internal base engine.
Engine is the type used as the first class template parameter (i.e. the type of engine being adapted).
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.

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 constructor
#include <iostream>
#include <chrono>
#include <random>

int main ()
{
  // ranlux24 is a standard discard_block_engine type:
  std::ranlux24 g1;

  std::ranlux24 g2(g1.base());

  std::ranlux24_base temp;
  std::ranlux24 g3(std::move(temp));

  unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
  std::ranlux24 g4(seed);

  std::seed_seq sseq ({2,16,77});
  std::ranlux24 g5(sseq);

  std::cout << "g1(): " << g1() << std::endl;
  std::cout << "g2(): " << g2() << std::endl;
  std::cout << "g3(): " << g3() << std::endl;
  std::cout << "g4(): " << g4() << std::endl;
  std::cout << "g5(): " << g5() << std::endl;

  return 0;
}

Possible output:
g1(): 15039276
g2(): 15039276
g3(): 15039276
g4(): 14445784
g5(): 14393633


Complexity Determined by the base engine.

See also
discard_block_engine::seed
Seed base engine (public member function)

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4