title: narrowing conversion from 'int' to 'double' and array initialization
body: <p>The following</p>
  
  <pre><code>int i = 0;
  double d{i};
  </code></pre>
  
  <p>gives an error (in clang) or warning (in gcc) of a <code>narrowing conversion from 'int' to 'double'</code>. I found it amazing that this is really narrowing, at least until I saw <a href="https://stackoverflow.com/questions/11521016/narrowing-conversion-from-unsigned-to-double">narrowing conversion from unsigned to double</a>.</p>
  
  <p>My <em>actual problem</em> originates from a class that contains an array and provides a constructor for specifying the elements of the array, in the simplest way possible (forwarding):</p>
  
  <pre><code>template&lt;typename T, size_t N&gt;
  struct A
  {
      T a[N];
  
      template&lt;typename... E&gt;
      A(E&amp;&amp;... e) : a{std::forward&lt;E&gt;(e)...} { }
  };
  </code></pre>
  
  <p>In this case, we have the following (<a href="http://coliru.stacked-crooked.com/a/5f84957980473a64" rel="nofollow noreferrer">live example</a>):</p>
  
  <pre><code>int i = 0;
  A&lt;double, 2&gt; x(i, 2);  // ERROR for both 'i' and '2'
  double y[2]{i, 2};     // ERROR for 'i' only
  </code></pre>
  
  <p>where <code>ERROR</code> refers to narrowing conversion as discussed above. I suspect that all those errors boil down to the one mentioned at the beginning (<code>double d{i};</code>). Is this so? Otherwise, what is happening?</p>
  
  <p>Anyhow, I would really like</p>
  
  <pre><code>A&lt;double, 2&gt; x(i, 2);
  </code></pre>
  
  <p>to work, exactly as</p>
  
  <pre><code>double x(i);
  </code></pre>
  
  <p>works. Unfortunately, I can only initialize the array using an initializer list, which also checks for narrowing conversions. I know one workaround is to make an explicit cast in the constructor:</p>
  
  <pre><code>template&lt;typename... E&gt;
  A(E&amp;&amp;... e) : a{static_cast &lt;T&gt;(e)...} { }
  </code></pre>
  
  <p>or (thanks Marc)</p>
  
  <pre><code>template&lt;typename... E&gt;
  A(E&amp;&amp;... e) : a{static_cast &lt;T&gt;(std::forward&lt;E&gt;(e))...} { }
  </code></pre>
  
  <p>but is this the "right" way? And is it the most efficient, when <code>E</code> is a "large" type?</p>