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:
parent
98705a61c9
commit
9a8679c733
10
random.hpp
10
random.hpp
@ -165,9 +165,11 @@ namespace cruft::random {
|
|||||||
if (data.empty ())
|
if (data.empty ())
|
||||||
return data.end ();
|
return data.end ();
|
||||||
|
|
||||||
return std::next (
|
auto const offset = uniform (
|
||||||
data.begin (),
|
typename ContainerT::size_type {0},
|
||||||
uniform (typename ContainerT::size_type {0}, data.size () - 1)
|
data.size () - 1
|
||||||
);
|
);
|
||||||
|
|
||||||
|
return std::next (data.begin (), offset);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user