title: How to properly static cast a vector in C++?
body: <p>I have a code in which at the end of a function I need to cast from int to double all the elements of an array in order to being able to do a final push_back before exiting the function. The code I have right now is:</p>
  
  <pre><code>template &lt;class T, size_t dims&gt; class A {
      typedef typename std::array&lt;int, dims&gt; ArrayInt;
      typedef typename std::array&lt;double, dims&gt; ArrayDouble;
      typedef typename std::vector &lt;ArrayDouble&gt; VectorDouble;
  
  /* ...*/
  
  foo() {
     /*  ...*/
  
     ArrayInt myArrayInt;
     ArrayDouble myArrayDouble;
     VectorDouble myVectorDouble;
  
      /* Initialize myArrayInt 
      Do some other stuff */
  
      for (int i = 0; i &lt; dims; ++i) 
          myArrayDouble[i] = static_cast&lt;double&gt;(myArrayInt[i]);
  
      myVectorDouble.push_back(myArrayDouble);
      }
  }
  </code></pre>
  
  <p>It works properly, but I do not feel comfortable about the lines:</p>
  
  <pre><code>for (int i = 0; i &lt; dims; ++i) 
      myArrayDouble[i] = static_cast&lt;double&gt;(myArrayInt[i]);
  </code></pre>
  
  <p>Is there any better way of doing this?</p>
  
  <p>Thank you.</p>