c++ - Multiply vector elements by a scalar value using STL -
hi want (multiply,add,etc) vector scalar value example myv1 * 3
, know can function forloop , there way of doing using stl function? {algorithm.h :: transform function }?
yes, using std::transform
:
std::transform(myv1.begin(), myv1.end(), myv1.begin(), std::bind1st(std::multiplies<t>(),3));
Comments
Post a Comment