File tree 1 file changed +11
-1
lines changed 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -2018,7 +2018,7 @@ Returns:
2018
2018
a copy.
2019
2019
*/
2020
2020
auto ref choice (Range , RandomGen = Random )(auto ref Range range,
2021
- ref RandomGen urng = rndGen )
2021
+ ref RandomGen urng)
2022
2022
if (isRandomAccessRange! Range && hasLength! Range && isUniformRNG! RandomGen)
2023
2023
{
2024
2024
assert (range.length > 0 ,
@@ -2027,6 +2027,12 @@ if (isRandomAccessRange!Range && hasLength!Range && isUniformRNG!RandomGen)
2027
2027
return range[uniform(size_t (0 ), $, urng)];
2028
2028
}
2029
2029
2030
+ // / ditto
2031
+ auto ref choice (Range )(auto ref Range range)
2032
+ {
2033
+ return choice (range, rndGen);
2034
+ }
2035
+
2030
2036
// /
2031
2037
@safe unittest
2032
2038
{
@@ -2041,6 +2047,10 @@ if (isRandomAccessRange!Range && hasLength!Range && isUniformRNG!RandomGen)
2041
2047
auto urng = Random (unpredictableSeed);
2042
2048
elem = choice(array, urng);
2043
2049
2050
+ assert (canFind(array, elem),
2051
+ " Choice did not return a valid element from the given Range" );
2052
+ auto rng2 = Xorshift();
2053
+ elem = choice(array, rng2);
2044
2054
assert (canFind(array, elem),
2045
2055
" Choice did not return a valid element from the given Range" );
2046
2056
}
You can’t perform that action at this time.
0 commit comments