passing a variadic parameter to randomSample

Ali Çehreli acehreli at yahoo.com
Wed Jan 26 16:41:53 UTC 2022


On 1/26/22 07:44, Ali Çehreli wrote:

 > the instantiations could be too many for R...

I am still wrong there. It is inconceivable to instantiate the following 
template for the same type (e.g. string) from "too many" places in a 
program:

auto RandomChoice(R...)(R r) {
   // ...
}

There may be a few instantiations that call it with 1, 2, 4... maybe 10 
arguments? But that would be it... Oh! Unless there is some code 
generation. :)

Ali



More information about the Digitalmars-d-learn mailing list