How can I select a random element in an std::set
?
I naively tried this:
int GetSample(const std::set<int>& s) {
double r = rand() % s.size();
return *(s.begin() + r); // compile error
}
But the operator+
is not allowed in this way.