...
Code Block | ||||
---|---|---|---|---|
| ||||
double data[5] = { 2.3, 3.7, 1.4, 0.8, 9.6 };
deque<double> d;
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> d;
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> d;
transform(data, data+5,
inserter(d, d.begin()),
bind2nd(plus<int>(), 41));
|
...
Rule | Severity | Likelihood | Remediation Cost | Priority | Level |
---|---|---|---|---|---|
ARR32-CPP | high | probable | high | P6 | L2 |
Bibliography
[Meyers 01] Item 43: Prefer algorithm calls to hand-written loops.
[Sutter 04] Item 84: Prefer algorithm calls to handwritten loops.
[Kalev 99] ANSI/ISO C++ Professional Programmer's Handbook.
[ISO/IEC 14882-2003] Section 24: Iterators Library.
...