C++ 转换向量<int>到向量<double>
转换 std::vector 到 std::vector.或者,更一般地说,转换两个可转换类型的向量?
What is a good clean way to convert a std::vector<int> intVec to std::vector<double> doubleVec. Or, more generally, to convert two vectors of convertible types?
推荐答案
使用 std::vector 的范围构造函数:
Use std::vector's range constructor:
std::vector<int> intVec;
std::vector<double> doubleVec(intVec.begin(), intVec.end());
相关文章