Skip to content

Commit

Permalink
Merge pull request #179 from MikeMirzayanov/dev-mikemirzayanov
Browse files Browse the repository at this point in the history
use std::advance
  • Loading branch information
MikeMirzayanov authored Sep 6, 2023
2 parents c3f7215 + 9e60dd4 commit 1818675
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions testlib.h
Original file line number Diff line number Diff line change
Expand Up @@ -887,7 +887,10 @@ class random_t {
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));
//return *(c.begin() + next(size));
typename Container::const_iterator it = c.begin();
std::advance(it, next(size));
return *it;
}

/* Returns random element from iterator range. */
Expand All @@ -896,7 +899,10 @@ class random_t {
int size = int(end - begin);
if (size <= 0)
__testlib_fail("random_t::any(const Iter& begin, const Iter& end): range must have positive length");
return *(begin + next(size));
// return *(begin + next(size));
Iter it = begin;
std::advance(it, next(size));
return *it;
}

/* Random string value by given pattern (see pattern documentation). */
Expand Down

0 comments on commit 1818675

Please sign in to comment.