Cpp Coding Standards/STL/PurePred
From Apache OpenOffice Wiki
< Cpp Coding Standards | STL
Revision as of 18:55, 22 May 2007 by Np (talk | contribs) (Cpp Coding Standards/The Cpp Standard Template Library/PurePred moved to Cpp Coding Standards/STL/PurePred: consistency)
A predicate should be a pure function (i.e. its result should depend only on its arguments). Prefer to make operator() const, to let any maintainer violating this trip over a compiler error.
Why should you keep predicates pure? Because STL assumes they are, and tend to make copies of your predicate. Violating this might work for your specific platform (compiler & STL), but will probably break mysteriously for others.