Giving random_pool the ability to construct random-filled objects.

This commit is contained in:
Piotr Wójcik 2023-03-07 21:15:33 +00:00 committed by Colin LeMahieu
commit 89baf79cb1
No known key found for this signature in database
GPG key ID: 43708520C8DFB938

View file

@ -19,6 +19,22 @@ public:
static uint64_t generate_word64 (uint64_t min, uint64_t max);
static unsigned char generate_byte ();
/** Fills variable with random data */
template <class T>
static void generate (T & out)
{
generate_block (reinterpret_cast<uint8_t *> (&out), sizeof (T));
}
/** Returns variable with random data */
template <class T>
static T generate ()
{
T t;
generate (t);
return t;
}
public:
random_pool () = delete;
random_pool (random_pool const &) = delete;
random_pool & operator= (random_pool const &) = delete;