struct Double
{
    double v = 0;
    alias v this;

struct Foo(size_t n)
{
    Double[n] bar;


Dne 10. 10. 2017 3:40 odpoledne napsal uživatel "Simon Bürger via Digitalmars-d-learn" <digitalmars-d-learn@puremagic.com>:
I have a static array inside a struct which I would like to be initialized to all-zero like so

  struct Foo(size_t n)
  {
    double[n] bar = ... all zeroes ...
  }

(note that the default-initializer of double is nan, and not zero)

I tried

  double[n] bar = 0;  // does not compile
  double[n] bar = {0}; // neither does this
  double[n] bar = [0]; // compiles, but only sets the first element, ignoring the rest

Is there a good way to set them all to zero? The only way I can think of is using string-mixins to generate a string such as "[0,0,0,0]" with exactly n zeroes. But that seems quite an overkill for such a basic task. I suspect I might be missing something obvious here...