how to do this meta-programming? print the address of random element's address of a variable length of arrays?
mw
mingwu at gmail.com
Sat Sep 12 01:44:30 UTC 2020
e.g.
int[] a = new int[la];
int[] b = new int[lb];
int[] c = new int[lc];
int[] d = new int[ld];
the func I want to write, e.g. for 2 arrays (instantiation) is
like this:
void print_random_elem_addr(int[] x, int[] y) {
auto i = random_int_between(0, x.length);
auto j = random_int_between(0, y.length);
print(&(x[i], &(y[j])); // only single print() func call
allowed!
}
But I want one generic function, which can be called as:
print_random_elem_addr(a, b);
print_random_elem_addr(a, b, c);
print_random_elem_addr(a, b, c, d);
...
My main question is how to meta-program (generate the parameter
list) this line:
print(&(x[i], &(y[j])); // only single print() func call
allowed!
Thanks!
More information about the Digitalmars-d-learn
mailing list