I have two vectors and I want to do something like
v2[i] = v1[i] +v2[i];
I have tried std::copy, but obviously that only do v2[i] = v1[i];
Is there any algorithm in the STL that performs this sum?
I have two vectors and I want to do something like
v2[i] = v1[i] +v2[i];
I have tried std::copy, but obviously that only do v2[i] = v1[i];
Is there any algorithm in the STL that performs this sum?
You can use std:::transform
std::transform(v1.begin(), v1.end(), v2.begin(), v2.begin(), std::plus<>());