18 #ifndef LUNCHBOX_RNG_H
19 #define LUNCHBOX_RNG_H
21 #include <lunchbox/debug.h>
22 #include <lunchbox/init.h>
24 #include <boost/noncopyable.hpp>
29 namespace detail {
class RNG; }
40 class RNG :
public boost::noncopyable
57 template<
typename T > T
get()
60 if( !_get( &value,
sizeof( T )))
66 LUNCHBOX_API
bool _get(
void* data,
size_t size );
71 const float max_limits =
72 static_cast< float >( std::numeric_limits< uint32_t >::max( ));
73 return ((
float)get< uint32_t >() / max_limits);
78 const double max_limits =
79 static_cast< double >( std::numeric_limits< uint64_t >::max( ));
80 return ((
double)get< uint64_t >() / max_limits);
85 return ( get< uint32_t >() & 1 );
88 #endif // LUNCHBOX_RNG_H
Basic type definitions not provided by the operating system.
A random number generator.
LUNCHBOX_API RNG()
Construct a new random number generator.
LUNCHBOX_API ~RNG()
Destruct the random number generator.
Abstraction layer and common utilities for multi-threaded programming.
T get()
Generate a random number.