public member function
<random>

std::random_device::random_device

explicit random_device (const string& token = /* see below */ );
Construct random device
Constructs a random_device object.

If the random_device cannot be initialized, an exception derived from the standard exception class is thrown.

Parameters

token
An identifier of a system-specific source of randomness.
The default value is a valid source for the system.
For example, on some implementations for linux systems, this parameter is interpreted as a filesystem path, and has a default value of "/dev/urandom".
string is a standard instantiation of basic_string.

Example

1
2
3
4
5
6
7
8
9
10
11
12
// random_device constructor
#include <iostream>
#include <random>

int main ()
{
  std::random_device rd;

  std::cout << "Random value: " << rd() << std::endl;

  return 0;
}


Possible output:
Random value: 2909135809

See also