On Tuesday, 23 May 2017 at 10:42:54 UTC, Nicholas Wilson wrote:
On Tuesday, 23 May 2017 at 10:30:56 UTC, Alex wrote:
On Monday, 22 May 2017 at 21:44:17 UTC, ag0aep6g wrote:
With that kind of variadics, you're not dealing with a template. A (run-time) variadic delegate is an actual delegate, i.e. a value that can be passed around. But the variadic stuff is a bit weird to use, and probably affects performance.

By the way, I'm not even sure, if variadics work in my case. I have a strange struct of a random generator, which cannot be copied, and I have no idea how to pass it to a variadic function:

import std.stdio;
import mir.random;

void main()
{
        Random rndGen = Random(unpredictableSeed);
        fun(rndGen);
}

void fun(...)
{

}

Yields "... is not copyable because it is annotated with @disable" :)

Random is copy @disabled to prevent incorrect use.

Yes, I'm aware of this...

You need to pass it by ref or pointer. I dont know if you can pass variables as ref to a variadic, but you should be able to pass it by address.
fun(&rndGen);

No, you can't pass a ref into a variadic... if the test above is written correct. And no, I can't pass it by adress, as I don't know apriori, whether the very parameter which gets the random generator is already a part of the variadic parameters, or a well defined ref parameter. Especially, there are some functions for both cases. While the argument list remains the same, the acceptor part is meant to work with it somehow. The other way around would be, to manipulate the argument list, which is shared...

Reply via email to