Loading…
CppCon 2016 has ended
Back To Schedule
Thursday, September 22 • 3:15pm - 4:15pm
I Just Wanted a Random Integer!

Log in to save this to your schedule, view media, leave feedback and see who's attending!

I just wanted to generate a random integer between 1 and 100 for my unit tests.

An hour later I was down the rabbit hole of the C++ <random> header wondering why it was so complicated, weren't rand() and modulo good enough and was <random> overkill, genius or both?

Several hours later I had watched STLs 2013 Going Native talk on <random> (go watch it!), read some blogs and had even more questions: does the mt19937 generator go on the heap? Just how cheap are uniform distributions to construct? Were there even better generators out there and were they easier to use? Oh and what is entropy? How do you put it in a pool and how can it be exhausted?

The story took a few unexpected twists and turns, but in the end I got my random integers, and answers to almost all my questions which I will share. Whether <random> is genius or overkill though, you will have to decide for yourself.

Speakers
CM

Cheinan Marks

Swarm64
As an engineer with a chemical engineering background, Cheinan is interested in practical code and wants to take the latest advances both in science and programming and use them in real life working code along with applying engineering principles to software development. Cheinan is... Read More →


Thursday September 22, 2016 3:15pm - 4:15pm PDT
Kantner (Room 403) Meydenbauer Center