Skip to content

Instantly share code, notes, and snippets.

@deque-blog
Created April 18, 2017 09:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save deque-blog/9c368a6719418f6cadd1e5c19dc1617c to your computer and use it in GitHub Desktop.
Save deque-blog/9c368a6719418f6cadd1e5c19dc1617c to your computer and use it in GitHub Desktop.
template<typename Container>
auto choice_gen(Container const& values)
{
return [=](std::mt19937& bit_gen) -> typename Container::value_type
{
std::uniform_int_distribution<int> distribution(0, values.size() - 1);
return values[distribution(bit_gen)];
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment