random: materialise the offset temporary for container choose

This helps a little in some debugging situations and isn't terrifically
expensive.
This commit is contained in:
Danny Robson 2019-05-12 11:31:29 +10:00
parent 98705a61c9
commit 9a8679c733

View File

@ -165,9 +165,11 @@ namespace cruft::random {
if (data.empty ())
return data.end ();
return std::next (
data.begin (),
uniform (typename ContainerT::size_type {0}, data.size () - 1)
auto const offset = uniform (
typename ContainerT::size_type {0},
data.size () - 1
);
return std::next (data.begin (), offset);
}
};
}