Steffen Brinkmann wrote:
> I tried to modify the transform algorithm in a way that it doesn't
> take iterators, but a reference to a container class and a value,
> because Mostly I need to do an operation of a container and a single
> number (e.g. multiply all the values in a vector by 3 or so).
In addition to WW's good comments, I thought I might add:
You might try out std::bind2nd in <functional> and stick with the
std::transform:
std::transform(v.begin(), v.end(), v.begin(),
std::bind2nd(std::multiplies<int>(), 3));
If you get into more complicated operations, boost::bind might provide
an answer (
www.boost.org ). boost::bind may eventually be
standardized. It has been voted into the first library technical report
which indicates an official interest in this library. The above
transform translates into bind with:
std::transform(v.begin(), v.end(), v.begin(),
boost::bind(std::multiplies<int>(), _1, 3));
-Howard