title: How to generate the same random number sequence over multiple types of compilers and kernels with <random>?
body: <h2>The problem</h2>
  
  <p>I need to produce the same (pseudo) random number sequence on different machines and compilers. If I use the same kernel, it seems that the implementetion of mersenne twister (MT) in g++ works well: regardless if I compile my program on a newer machine, with g++ 4.9 or 4.7, I get the same random numbers. But I get different ones if I use older kernel or if I change to Visual Studio's compiler. That's ok, because there's no gurantee that <code>mersenne_twister_engine::seed</code> sets the internal state to the same over different compilers.</p>
  
  <h3>What I've already tried</h3>
  
  <p>I tought that applying <code>operator&lt;&lt;</code> on the generator produces a unique result that can be used to set the generators on other machines with the <code>operator&gt;&gt;</code>, but in case of <code>mt19937</code>, it seems it is not working. To make it clear, on a computer A I had the code </p>
  
  <pre><code>mt19937 generator1A;
  uniform_int_distribution&lt;int&gt; distribution(0, 1000);
  
  cout &lt;&lt; "Generating random numbers with seed 1000" &lt;&lt; endl;
  
  generator1A.seed(1000);
  generator1A(); //to advance the state by one so operator&gt;&gt; will give a longer output; this is not necessary indeed
  ofstream test("testseed1000.txt");
  test &lt;&lt; generator1A &lt;&lt; endl;
  
  for (int i = 0; i &lt; 10; ++i)
      cout &lt;&lt; distribution(generator1A) &lt;&lt; endl;
  </code></pre>
  
  <p>And it produces 252, 590, 893, ..., and a long file. I transfer the file to the other machine B, and run the following code:</p>
  
  <pre><code>mt19937 generator1B, generator2B;
  uniform_int_distribution&lt;int&gt; distribution(0, 1000);
  
  cout &lt;&lt; "Generating random numbers with seed 1000, and with operator&gt;&gt;" &lt;&lt; endl;
  generator2B.seed(1000);
  generator2B(); // to advance the state by one here as well
  
  ifstream test("testseed1000.txt");
  
  test &gt;&gt; generator1B;
  cout &lt;&lt; "************************" &lt;&lt; endl;
  cout &lt;&lt; generator1B &lt;&lt; endl;
  cout &lt;&lt; "************************" &lt;&lt; endl;
  cout &lt;&lt; "With seed\twith operator&gt;&gt;" &lt;&lt; endl;
  
  for (int i = 0; i &lt; 10; ++i)
      cout &lt;&lt; distribution(generator2B) &lt;&lt; "\t" &lt;&lt; distribution(generator1B) &lt;&lt; endl;
  </code></pre>
  
  <p>And it produces</p>
  
  <pre><code>654     205
  205     115
  115     610
  </code></pre>
  
  <h2>The question</h2>
  
  <p>Can you give advices how to generate the same (pseudo) random numbers with at least VC++ on Windows and g++ on Debian and Ubuntu? I'd like to use std if it is possible and I wouldn't like to implement my own MT engine.</p>
  
  <h3>Notes:</h3>
  
  <ul>
  <li>creating millions of random numbers and then reading in is not a solution</li>
  <li>I have to use MSVS for code developing and unix servers for simulation</li>
  <li>other than MT engines are also welcomed but I prefer MT</li>
  </ul>