Giving random_pool the ability to construct random-filled objects.
This commit is contained in:
parent
76dcdaccab
commit
89baf79cb1
1 changed files with 16 additions and 0 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue