digitalmars.D.learn - How can I implement this in D: a variant array of varying function
- Enjoys Math (9/9) Jan 17 2017 Z add(Z...)(Z a...) {
- Enjoys Math (2/11) Jan 17 2017 func? I mean std.variant.Variant there.
- Nicholas Wilson (3/12) Jan 17 2017 Try using `variantArray` from std.variant. see
Z add(Z...)(Z a...) { return a + b; } func[] operatorPool = [&add!int]; Variant library isn't liking that. Removing & causes another error. Essentially I want a pool of all operators that I define, but these operators can be of differing types (which I should be able to programatically grab), and different N-aryness.
Jan 17 2017
On Tuesday, 17 January 2017 at 10:49:14 UTC, Enjoys Math wrote:Z add(Z...)(Z a...) { return a + b; } func[] operatorPool = [&add!int]; Variant library isn't liking that. Removing & causes another error. Essentially I want a pool of all operators that I define, but these operators can be of differing types (which I should be able to programatically grab), and different N-aryness.func? I mean std.variant.Variant there.
Jan 17 2017
On Tuesday, 17 January 2017 at 10:49:14 UTC, Enjoys Math wrote:Z add(Z...)(Z a...) { return a + b; } func[] operatorPool = [&add!int]; Variant library isn't liking that. Removing & causes another error. Essentially I want a pool of all operators that I define, but these operators can be of differing types (which I should be able to programatically grab), and different N-aryness.Try using `variantArray` from std.variant. see https://dlang.org/phobos/std_variant.html#.variantArray
Jan 17 2017