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:
template <class T, size_t dims> class A {
    typedef typename std::array<int, dims> ArrayInt;
    typedef typename std::array<double, dims> ArrayDouble;
    typedef typename std::vector <ArrayDouble> VectorDouble;
/* ...*/
foo() {
   /*  ...*/
   ArrayInt myArrayInt;
   ArrayDouble myArrayDouble;
   VectorDouble myVectorDouble;
    /* Initialize myArrayInt 
    Do some other stuff */
    for (int i = 0; i < dims; ++i) 
        myArrayDouble[i] = static_cast<double>(myArrayInt[i]);
    myVectorDouble.push_back(myArrayDouble);
    }
}
It works properly, but I do not feel comfortable about the lines:
for (int i = 0; i < dims; ++i) 
    myArrayDouble[i] = static_cast<double>(myArrayInt[i]);
Is there any better way of doing this?
Thank you.
 
     
    