Here is working code:
#include <iostream>
#include <random>
int main() {
std::random_device rd;
std::mt19937 gen(rd());
std::binomial_distribution<> d(5, 1.0/6.0);
std::cout << d(gen) << std::endl;
}
You can check its result here, and it works with recent GCC and Clang versions. Please note that it is generally better to use the random_device instead of time to get a seed.
Compile it with the --std=c++11
.