<div dir="auto"><div>struct Double<div dir="auto">{</div><div dir="auto">    double v = 0;</div><div dir="auto">    alias v this;</div><div dir="auto">} </div><div dir="auto"><br></div>struct Foo(size_t n)</div><div dir="auto">{</div><div dir="auto">    Double[n] bar;</div><div dir="auto">} <br><div class="gmail_extra" dir="auto"><br><div class="gmail_quote">Dne 10. 10. 2017 3:40 odpoledne napsal uživatel "Simon Bürger via Digitalmars-d-learn" <<a href="mailto:digitalmars-d-learn@puremagic.com">digitalmars-d-learn@puremagic.com</a>>:<br type="attribution"><blockquote class="quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I have a static array inside a struct which I would like to be initialized to all-zero like so<br>
<br>
  struct Foo(size_t n)<br>
  {<br>
    double[n] bar = ... all zeroes ...<br>
  }<br>
<br>
(note that the default-initializer of double is nan, and not zero)<br>
<br>
I tried<br>
<br>
  double[n] bar = 0;  // does not compile<br>
  double[n] bar = {0}; // neither does this<br>
  double[n] bar = [0]; // compiles, but only sets the first element, ignoring the rest<br>
<br>
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...<br>
</blockquote></div><br></div></div></div>