AzerothCore 3.3.5a
OpenSource WoW Emulator
Loading...
Searching...
No Matches
SFMTRand Class Reference

#include "SFMTRand.h"

Public Member Functions

 SFMTRand ()
 
uint32 RandomUInt32 ()
 
void * operator new (std::size_t size, std::nothrow_t const &)
 
void operator delete (void *ptr, std::nothrow_t const &)
 
void * operator new (std::size_t size)
 
void operator delete (void *ptr)
 
void * operator new[] (std::size_t size, std::nothrow_t const &)
 
void operator delete[] (void *ptr, std::nothrow_t const &)
 
void * operator new[] (std::size_t size)
 
void operator delete[] (void *ptr)
 

Private Attributes

sfmt_t _state
 

Detailed Description

Constructor & Destructor Documentation

◆ SFMTRand()

SFMTRand::SFMTRand ( )
60{
61 std::random_device dev;
62
63 if (dev.entropy() > 0)
64 {
65 std::array<uint32, SFMT_N32> seed;
66 std::generate(seed.begin(), seed.end(), std::ref(dev));
67
68 sfmt_init_by_array(&_state, seed.data(), seed.size());
69 }
70 else
71 {
72 sfmt_init_gen_rand(&_state, uint32(GetEpochTime().count()));
73 }
74}
Seconds GetEpochTime()
Definition: Timer.h:141
std::uint32_t uint32
Definition: Define.h:107
sfmt_t _state
Definition: SFMTRand.h:42

References _state, and GetEpochTime().

Member Function Documentation

◆ operator delete() [1/2]

void SFMTRand::operator delete ( void *  ptr)
97{
98 _mm_free(ptr);
99}

◆ operator delete() [2/2]

void SFMTRand::operator delete ( void *  ptr,
std::nothrow_t const &   
)
87{
88 _mm_free(ptr);
89}

◆ operator delete[]() [1/2]

void SFMTRand::operator delete[] ( void *  ptr)
117{
118 _mm_free(ptr);
119}

◆ operator delete[]() [2/2]

void SFMTRand::operator delete[] ( void *  ptr,
std::nothrow_t const &   
)
107{
108 _mm_free(ptr);
109}

◆ operator new() [1/2]

void * SFMTRand::operator new ( std::size_t  size)
92{
93 return _mm_malloc(size, 16);
94}

◆ operator new() [2/2]

void * SFMTRand::operator new ( std::size_t  size,
std::nothrow_t const &   
)
82{
83 return _mm_malloc(size, 16);
84}

◆ operator new[]() [1/2]

void * SFMTRand::operator new[] ( std::size_t  size)
112{
113 return _mm_malloc(size, 16);
114}

◆ operator new[]() [2/2]

void * SFMTRand::operator new[] ( std::size_t  size,
std::nothrow_t const &   
)
102{
103 return _mm_malloc(size, 16);
104}

◆ RandomUInt32()

uint32 SFMTRand::RandomUInt32 ( )
77{
78 return sfmt_genrand_uint32(&_state);
79}

References _state.

Referenced by rand32().

Member Data Documentation

◆ _state

sfmt_t SFMTRand::_state
private

Referenced by RandomUInt32(), and SFMTRand().