Wiki Markup |
---|
Reallocation can occur when a member function modifies its container. Modifying member functions include {{reserve()}} and {{resize()}}, {{push_back()}}, {{pop_back()}}, {{erase()}}, {{clear()}}, {{insert()}}, and others. In addition, assignment operations and modifying algorithms can also cause reallocation. When a container reallocates its elements, their addresses change. Consequently, the values of existing iterators are invalidated \[[Kalev 99|AA. C++ References#Kalev 99]\]. Using invalid iterators yields undefined results. (This problem is also discussed in [DAN33-C. Do not use invalid iterators].) |
Non-Compliant Code Example
...
Rule | Severity | Likelihood | Remediation Cost | Priority | Level |
---|---|---|---|---|---|
STL30-C | 1 3 (lowhigh) | 2 (probable) | 1 (high) | P2 P6 | L3 L2 |
References
Wiki Markup |
---|
\[[Meyers 01|AA. C++ References#Meyers 01]\] Item 43: Prefer algorithm calls to hand-written loops. |
...