Echo89

C++11 random code generator ONLY FOR C++ 11

Nov 20th, 2012
79
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. string random(size_t len)
  2. {
  3.     static const string a = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
  4.     static mt19937 x(time(NULL));
  5.     static uniform_int_distribution<size_t> d(0, a.size() - 1);
  6.     string r;
  7.     srand(time(NULL));
  8.     for(size_t i = 0; i < len; i++) r += a.at[d(x)];
  9.     return r;
  10. }
RAW Paste Data