passing a variadic parameter to randomSample

Ali Çehreli acehreli at yahoo.com
Wed Jan 26 15:44:57 UTC 2022


On 1/26/22 02:20, Stanislav Blinov wrote:
 > On Tuesday, 25 January 2022 at 22:07:43 UTC, Ali Çehreli wrote:
 >> On 1/25/22 13:55, forkit wrote:
 >>
 >> > auto RandomChoice(R...)(R r)
 >>
 >> Watch out though: The compiler will compile a different function per
 >> set of values. For example, there will be separate RandomChoice
 >> instances for ("hello") vs. ("world").
 >
 > Huh? Perhaps you meant "for ("hello") vs. ("hello", "world")"? Because
 > it would be the same instantiation for a single string argument :)

You're right. I mistakenly assumed it would be the same as 
RandomChoice(string a, string b)(). But still, as you show, the 
instantiations could be too many for R...

Ali



More information about the Digitalmars-d-learn mailing list