What is a good way to get a [pseudo-]random element from an STL range?
The best I can come up with is to do std::random_shuffle(c.begin(), c.end()) an
std::random_shuffle(c.begin(), c.end())
This works fine as long as RAND_MAX is much greater than the container size, otherwise it suffers from the bias problem cited by Alexandre:
vector::iterator randIt = myvector.begin(); std::advance(randIt, std::rand() % myvector.size());