STL containers that take predicate functors are perfectly free to make multiple copies of the predicate, and often do, because typically predicates are passed by value. (\[[Meyers 01|AA. Bibliography#Meyers 01]\] Item 38) If a predicate stores and uses internal state, then its state values at the end of a predicate-based function call are implementation-defined, and usually unexpected. Wiki Markup
Non-Compliant Code Example
...
Rule | Severity | Likelihood | Remediation Cost | Priority | Level |
---|---|---|---|---|---|
ARR44-CPP | low | likely | high | P3 | L3 |
Bibliography
...
\[[Meyers 01|AA. Bibliography#Meyers 01]\] Item 39: Make predicates pure functions
...
ARR43-CPP. Do not access collapsed elements from a remove(), remove_if() or unique() operation 06. Arrays and the STL (ARR) 07. Characters and Strings (STR)