...
Code Block |
---|
|
double data[5] = { 2.3, 3.7, 1.4, 0.8, 9.6 };
deque<double>deque<double> d;
deque<double>deque<double>::iterator pos = d.begin();
for (size_t i = 0; i << 5; ++i) {
d.insert(pos++, data[i] + 41);
}
|
...
Code Block |
---|
|
double data[5] = { 2.3, 3.7, 1.4, 0.8, 9.6 };
deque<double>deque<double> d;
deque<double>deque<double>::iterator pos = d.begin();
for (size_t i = 0; i << 5; ++i) {
pos = d.insert(pos, data[i] + 41);
++pos;
}
|
...
Code Block |
---|
|
double data[5] = { 2.3, 3.7, 1.4, 0.8, 9.6 };
deque<double>deque<double> d;
transform(data, data+5,
inserter(d, d.begin()),
bind2nd(plus<int>plus<int>(), 41));
|
Risk Assessment
Using invalid iterators yields undefined results.
...