title: Efficiently generating random bytes of data in C++11/14
body: <p>My requirement is to generate random bytes of data <em>(not random numbers)</em> aka uniformly distributed bits.</p>
  
  <p>As such I was wondering what are the correct/efficient ways of doing this using C++11/14 random facilities. I've had a look around at the examples, but they <strong><em>all</em></strong> seem to focus on number generation <em>(ints, floats etc)</em></p>
  
  <p>Current solution I'm using is the following:</p>
  
  <pre><code>#include &lt;vector&gt;
  #include &lt;random&gt;
  
  int main()
  {
     std::random_device rd;
     std::uniform_int_distribution&lt;int&gt; dist(0,255);
     std::vector&lt;char&gt; data(1000);
     for (char&amp; d : data)
     {
        d = static_cast&lt;char&gt;(dist(rd) &amp; 0xFF);
     }
     return 0;
  }
  </code></pre>