Posts

Showing posts with the label randomness

C++ : The unrandom random number...

Image
I've been working in some C++, with boost to be precise, the machine I'm working towards finally has a processor with SSE3 in it, and so I've been to revisit the GUID generation code, boost specifies a couple of defines you can set up before incluiding the uuids header to help... #include <iostream> #ifndef BOOST_UUID_USE_SSE3 #define BOOST_UUID_USE_SSE3 #endif #include <boost/uuid/uuid.hpp> #include <boost/uuid/uuid_io.hpp> #include <boost/uuid/uuid_generators.hpp> #include <boost/lexical_cast.hpp> const std::string GetGuid(); int main () { for (unsigned int i(0); i < 100000; ++i) { std::cout << GetGuid() << "\r\n"; } } const std::string GetGuid() { boost::uuids::uuid l_guid = boost::uuids::random_generator()(); return boost::lexical_cast<std::string>(l_guid); } This code looks fairly innocuous, "GetGuid" is the key part, you may argue that you're always setting the random number gener...