|
@@ -173,6 +173,7 @@ const char *latestFeatures[] = {
|
|
|
#include <map>
|
|
|
#include <set>
|
|
|
#include <cmath>
|
|
|
+#include <iterator>
|
|
|
#include <iostream>
|
|
|
#include <sstream>
|
|
|
#include <fstream>
|
|
@@ -901,7 +902,6 @@ public:
|
|
|
int size = int(c.size());
|
|
|
if (size <= 0)
|
|
|
__testlib_fail("random_t::any(const Container& c): c.size() must be positive");
|
|
|
- //return *(c.begin() + next(size));
|
|
|
typename Container::const_iterator it = c.begin();
|
|
|
std::advance(it, next(size));
|
|
|
return *it;
|
|
@@ -910,10 +910,9 @@ public:
|
|
|
/* Returns random element from iterator range. */
|
|
|
template<typename Iter>
|
|
|
typename Iter::value_type any(const Iter &begin, const Iter &end) {
|
|
|
- int size = int(end - begin);
|
|
|
+ int size = static_cast<int>(std::distance(begin, end));
|
|
|
if (size <= 0)
|
|
|
__testlib_fail("random_t::any(const Iter& begin, const Iter& end): range must have positive length");
|
|
|
- // return *(begin + next(size));
|
|
|
Iter it = begin;
|
|
|
std::advance(it, next(size));
|
|
|
return *it;
|
|
@@ -1105,7 +1104,6 @@ public:
|
|
|
size_t size = c.size();
|
|
|
if (size <= 0)
|
|
|
__testlib_fail("random_t::wany(const Container& c, int type): c.size() must be positive");
|
|
|
- // return *(c.begin() + wnext(size, type));
|
|
|
typename Container::const_iterator it = c.begin();
|
|
|
std::advance(it, wnext(size, type));
|
|
|
return *it;
|
|
@@ -1114,11 +1112,10 @@ public:
|
|
|
/* Returns weighted random element from iterator range. */
|
|
|
template<typename Iter>
|
|
|
typename Iter::value_type wany(const Iter &begin, const Iter &end, int type) {
|
|
|
- int size = int(end - begin);
|
|
|
+ int size = static_cast<int>(std::distance(begin, end));
|
|
|
if (size <= 0)
|
|
|
__testlib_fail(
|
|
|
"random_t::any(const Iter& begin, const Iter& end, int type): range must have positive length");
|
|
|
- // return *(begin + wnext(size, type));
|
|
|
Iter it = begin;
|
|
|
std::advance(it, wnext(size, type));
|
|
|
return *it;
|