title: C++ Template Class Constructor with Variable Arguments
body: <p>Is it possible to create a template function that takes a variable number of arguments, for example, in this <code>Vector&lt; T, C &gt;</code> class constructor:</p>
  
  <pre><code>template &lt; typename T, uint C &gt;
  Vector&lt; T, C &gt;::Vector( T, ... )
  {
      va_list arg_list;
      va_start( arg_list, C );
      for( uint i = 0; i &lt; C; i++ ) {
          m_data[ i ] = va_arg( arg_list, T );
      }
      va_end( arg_list );
  }
  </code></pre>
  
  <p>This almost works, but if someone calls <code>Vector&lt; double, 3 &gt;( 1, 1, 1 )</code>, only the first argument has the correct value. I suspect that the first parameter is correct because it is cast to a <code>double</code> during the function call, and that the others are interpreted as <code>int</code>s and then the bits are stuffed into a <code>double</code>. Calling <code>Vector&lt; double, 3 &gt;( 1.0, 1.0, 1.0 )</code> gives the desired results. Is there a preferred way to do something like this?</p>