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

Popular posts from this blog

ASP.NET/SQL find the element ID and update database -

jquery - appear modal windows bottom -

c++ - Compiling static TagLib 1.6.3 libraries for Windows -