// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+#include <iterator>
#include <map>
#include <set>
#include <boost/scoped_ptr.hpp>
template <typename T>
typename T::iterator rand_choose(T &cont) {
- if (cont.size() == 0) {
- return cont.end();
+ if (std::empty(cont)) {
+ return std::end(cont);
}
- int index = rand() % cont.size();
- typename T::iterator retval = cont.begin();
-
- for (; index > 0; --index) ++retval;
- return retval;
+ return std::next(std::begin(cont), rand() % cont.size());
}
string random_string(size_t size)