I am trying to implement a PRNG I found online yet I am having compile time issues (seen below):
1>c:\program files (x86)\microsoft visual studio\2017\community\vc\tools\msvc\14.15.26726\include\xutility(4010): error C2061: syntax error: identifier 'result_type'
1>c:\program files (x86)\microsoft visual studio\2017\community\vc\tools\msvc\14.15.26726\include\xutility(4012): error C2065: '_Ty1': undeclared identifier
1>c:\program files (x86)\microsoft visual studio\2017\community\vc\tools\msvc\14.15.26726\include\xutility(4012): error C2065: '_Ty1': undeclared identifier
1>c:\program files (x86)\microsoft visual studio\2017\community\vc\tools\msvc\14.15.26726\include\xutility(4012): error C2923: 'std::conditional_t': '_Ty1' is not a valid template type argument for parameter '_Ty2'
This is my code:
std::random_device rd;
small_prng engine;
std::uniform_int_distribution< int > ud( 0, 50 );
for ( auto i = 0; i < 100; i++ ) {
printf( "%i\n", ud( engine ) );
}
And this is the code I got online...
class small_prng {
uint32_t a;
uint32_t b;
uint32_t c;
uint32_t d;
static inline uint32_t rot( uint32_t x, uint32_t k ) noexcept {
return ( ( ( x ) << ( k ) ) | ( ( x ) >> ( 32 - ( k ) ) ) );
}
public:
using value_type = uint32_t;
explicit small_prng( uint32_t seed = 0xdeadbeef ) noexcept {
a = 0xf1ea5eed;
b = c = d = seed;
for ( size_t i = 0; i < 20; ++i )
( *this )( );
}
inline uint32_t operator()( ) noexcept {
uint32_t e = a - rot( b, 27 );
a = b ^ rot( c, 17 );
b = c + d;
c = d + e;
d = e + a;
return d;
}
};
Is there any reason this isn't working? How come? Compiling using Visual Studio 2017.
Aucun commentaire:
Enregistrer un commentaire