Faker C++
Loading...
Searching...
No Matches
random_generator.h
Go to the documentation of this file.
1#pragma once
2
3#include <random>
4#include <type_traits>
5
6namespace faker
7{
8template <typename T>
9 requires std::uniform_random_bit_generator<T>
10
12{
13public:
14 RandomGenerator() : generator_{T(std::random_device{}())} {}
15
16 ~RandomGenerator() = default;
17
22
23 template <typename Dist>
24 requires std::is_invocable_r_v<int, Dist&, T&>
25
26 int operator()(Dist&& dist)
27 {
28 return std::forward<Dist>(dist)(generator_);
29 }
30
31private:
33};
34}
Definition random_generator.h:12
int operator()(Dist &&dist)
Definition random_generator.h:26
RandomGenerator()
Definition random_generator.h:14
RandomGenerator & operator=(const RandomGenerator &)=default
RandomGenerator(const RandomGenerator &)=default
T generator_
Definition random_generator.h:32
RandomGenerator & operator=(RandomGenerator &&)=default
RandomGenerator(RandomGenerator &&)=default
Definition airline.h:9