hand-written loop
// this function takes a pointer to an array of at most arraySize
// doubles and writes data to it. It returns the number of doubles written.
size_t fillArray(double *pArray, size_t arraySize);
double data[maxNumDoubles];
size_t numDoubles = fillArray(data, maxNumDoubles);
deque<doble> d;
...
deque<double>::iterator insertLocation = d.begin();
for (size_t i = 0; i < numDoubles; ++i) {
insertLocation = d.insert(insertLocation, data[i] + 41);
++ insertLocation;
}
algorithm call
transform(data, data + numDoubles, // copy all elements
inserter(d, d.begin()), // store the result in this range
bind2nd(plus<double>(), 41)); // adding 41 to each.sessss