title: Possible to initialize const std::array with repeated function call?
body: <p>Is it possible to do this</p>
  
  <pre><code>int foo(){
    static int i=0;
    ret = i++;
    return ret;
  }
  const std::array&lt;int,3&gt; arr = {{foo(),foo(),foo()}};
  </code></pre>
  
  <p>in a (template?) function or a way that specifies "call foo for the initialization of every member"?i.e.</p>
  
  <pre><code>const std::array&lt;int,3&gt; arr = fill_with_foo&lt;3,foo&gt;();
  </code></pre>
  
  <p>For context,arr is a buffer from a queue from which N elements will be read (known at compile time). Currently I am using code generation to create the long form, and I have a function which simply allocates a normal array, fills it with a for loop and returns the array, but I wonder if it is possible to have the buffer array const. </p>
  
  <p>//Edit: unlike in the linked "duplicate", I need </p>
  
  <pre><code>int foo();
  </code></pre>
  
  <p>to be nondeterministic at compile time, i.e. I think constexpr is out of the question (as I said, it needs to read from a queue which is filled at runtime). I am mainly interested in eliding useless copies </p>