// discrete_distribution
#include <iostream>
#include <random>
int main()
{
constint nrolls = 10000; // number of experiments
constint nstars = 100; // maximum number of stars to distribute
std::default_random_engine generator;
std::discrete_distribution<int> distribution {2,2,1,1,2,2,1,1,2,2};
int p[10]={};
for (int i=0; i<nrolls; ++i) {
int number = distribution(generator);
++p[number];
}
std::cout << "a discrete_distribution:" << std::endl;
for (int i=0; i<10; ++i)
std::cout << i << ": " << std::string(p[i]*nstars/nrolls,'*') << std::endl;
return 0;
}
But it does not compile. This is the first error I get for line 11:
error C2601: 'distribution' : local function definitions are illegal
This now gives an error for the third line in your code: error C2661: 'std::discrete_distribution<_Ty>::discrete_distribution' : no overloaded function takes 2 arguments
It appears that VS2012 missing iterator constructor as well...
Well, only way to initialize it is to use last consructor and ugly hack (I hope at least lambdas are properly supported):