On Monday, 15 July 2019 at 14:50:20 UTC, Paul Backus wrote:
Use a run-time Tuple instead of an AliasSeq:
import std.typecons;
auto args = tuple(0, 0);
static foreach (idx, val; args) {
static if (user_defined_function_exists_for_arg!idx) {
args[idx] = user_defined_function();
}
On Monday, 15 July 2019 at 13:40:29 UTC, Ben Ogles wrote:
Now I want to extend it so that a caller can specify the values
of only some of the parameters. I tried using a static foreach
instead of the staticMap function. But I can't modify AliasSeq
values.
alias args = AliasSeq!(0, 0);
static
On Monday, 15 July 2019 at 14:15:41 UTC, Stefan Koch wrote:
On Monday, 15 July 2019 at 13:40:29 UTC, Ben Ogles wrote:
I have written a simple function that can call another
function over integral types with random arguments:
[...]
You cannot. meta-programming and compile-time evaluation are
On Monday, 15 July 2019 at 13:40:29 UTC, Ben Ogles wrote:
I have written a simple function that can call another function
over integral types with random arguments:
[...]
You cannot. meta-programming and compile-time evaluation are
supposed to be deterministic,
and hence cannot take random
I have written a simple function that can call another function
over integral types with random arguments:
auto rnd = Random(42);
auto rand_integral(T)() {
return uniform(T.min, T.max, rnd);
}
auto call_with_rand(alias fun)() {
fun(staticMap!(get_rand_integral, Parameters!fun));
}
Now I