Don't rely on [] operator in random::uniform_from
This commit is contained in:
parent
7c20a91546
commit
ed1764ffea
1 changed files with 1 additions and 1 deletions
|
|
@ -60,7 +60,7 @@ namespace psemek::random
|
|||
{
|
||||
if (container.empty())
|
||||
throw std::runtime_error("cannot sample from empty container");
|
||||
return container[uniform<std::size_t>(rng, 0, container.size() - 1)];
|
||||
return *std::next(container.begin(), uniform<std::size_t>(rng, 0, container.size() - 1));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue