title: Passing primitive array to function with std::initializer_list argument
body: <p>With the a function taking std::initializer_list as argument like shown below</p>
  
  <pre><code>int sumOf(std::initializer_list&lt;int&gt; numbers) {
      int sum = 0;  
      for (auto x : numbers) {
          sum += x;
      }
      return sum;
  }
  </code></pre>
  
  <p>This code works  </p>
  
  <p><code>auto sum = sumOf({ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 });</code>  </p>
  
  <p>but not this   </p>
  
  <pre><code> int i[]  = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
   auto x = sumOf(i);
  </code></pre>
  
  <p>Why does the second form not work? Or am I doing something wrong?</p>
  
  <p><strong>Edit:</strong><br>
  From the gcc 4.7.2 implementation of std::intializer_list, the constructor of intializer_list is private and compiler needs to pass the size of the array. </p>
  
  <pre><code>  // The compiler can call a private constructor.
    constexpr initializer_list(const_iterator __a, size_type __l)
    : _M_array(__a), _M_len(__l) { }
  </code></pre>
  
  <p>I guess the compiler cannot judge the size of the array from the variable "i" in certain cases. If so, passing static array to intializer_list cannot be supported by the compiler (?).</p>