C++ convert vector<int> to vector<double>
Solution 1:
Use std::vector
's range constructor:
std::vector<int> intVec;
std::vector<double> doubleVec(intVec.begin(), intVec.end());
Solution 2:
Use std::transform
algorithm:
std::transform(intVec.begin(), intVec.end(), doubleVec.begin(), [](int x) { return (double)x;});