idfxx 1.0.0
Modern C++23 components for ESP-IDF
Loading...
Searching...
No Matches
idfxx::random_device Class Reference

Hardware random number generator satisfying UniformRandomBitGenerator. More...

Public Types

using result_type = uint32_t
 The type of random values produced.
 

Public Member Functions

result_type operator() () noexcept
 Generates a random value.
 

Static Public Member Functions

static constexpr result_type min () noexcept
 Returns the minimum value that can be generated.
 
static constexpr result_type max () noexcept
 Returns the maximum value that can be generated.
 

Detailed Description

Hardware random number generator satisfying UniformRandomBitGenerator.

Can be used with standard library distributions and algorithms that require a random bit source.

std::uniform_int_distribution<int> dist(1, 6);
int die_roll = dist(rng);
Hardware random number generator satisfying UniformRandomBitGenerator.
Definition random.hpp:80
std::expected< T, std::error_code > result
result type wrapping a value or error code.
Definition error.hpp:120

Definition at line 80 of file random.hpp.

Member Typedef Documentation

◆ result_type

The type of random values produced.

Definition at line 83 of file random.hpp.

Member Function Documentation

◆ max()

static constexpr result_type idfxx::random_device::max ( )
inlinestaticconstexprnoexcept

Returns the maximum value that can be generated.

Returns
The maximum uint32_t value.

Definition at line 97 of file random.hpp.

◆ min()

static constexpr result_type idfxx::random_device::min ( )
inlinestaticconstexprnoexcept

Returns the minimum value that can be generated.

Returns
0.

Definition at line 90 of file random.hpp.

◆ operator()()

result_type idfxx::random_device::operator() ( )
inlinenoexcept

Generates a random value.

Returns
A hardware-generated random 32-bit value.

Definition at line 104 of file random.hpp.


The documentation for this class was generated from the following file: