compiler error when trying to get random key from AA

Basile B. b2.temp at gmx.com
Sat Jan 25 09:10:58 UTC 2020


On Saturday, 25 January 2020 at 09:06:53 UTC, mark wrote:
> On Saturday, 25 January 2020 at 08:59:23 UTC, Basile B. wrote:
>> On Saturday, 25 January 2020 at 08:35:18 UTC, mark wrote:
>>> [...]
> [snip]
>>> [...]
>>
>> rndGen is a range.
>>
>> Use `auto word = aa.byKey.choice(rnd.front())` as index 
>> instead.
>> Then `rndGen.popFront()` to advance.
>
> I tried that. It doesn't solve the problem but does reduce the 
> size of the error output to:
>
> onlineapp.d(9): Error: template std.random.choice cannot deduce 
> function from argument types !()(Result, uint), candidates are:
> /dlang/dmd/linux/bin64/../../src/phobos/std/random.d(2599):
>  choice(Range, RandomGen = Random)(auto ref Range range, ref 
> RandomGen urng)
> /dlang/dmd/linux/bin64/../../src/phobos/std/random.d(2609):
>  choice(Range)(auto ref Range range)

yeah indeed. sorry, I didn't read and thought you needed the 
index of rndGen, e.g index % upperBound.


More information about the Digitalmars-d-learn mailing list