On Saturday, 11 March 2017 at 12:35:42 UTC, XavierAP wrote:
I do not really think it's a bad solution, to check several scalar arguments that must obey the same condition; just wondering if you have better ideas. Try to avoid modifying the function's signature and defining custom types, unless you have a really terrific idea.

void calc(double in1, double in2, double in3, double in4)
in {
   foreach(const p; [&in1, &in2, &in3, &in4])
      enforce(*p > 0);
}
body { /* ... */ }

Please imagine double is a type that I wanted to avoid copying, just check by ref. Same question :p

Reply via email to