Skip to content

Instantly share code, notes, and snippets.

@ayyess
Created December 29, 2015 11:39
Show Gist options
  • Save ayyess/5376ea7b61c5b1defb54 to your computer and use it in GitHub Desktop.
Save ayyess/5376ea7b61c5b1defb54 to your computer and use it in GitHub Desktop.
#include <random>
class Maybe {
std::mt19937 rng;
std::bernoulli_distribution coin;
public:
operator bool() { return coin(rng); }
} maybe;
#include <iostream>
using std::cout;
using std::endl;
int main(int argc, char *argv[])
{
for (int i = 0; i < 10; ++i) {
bool a = maybe;
cout << a << endl;
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment