Difference between revisions of "Cpp Coding Standards/STL/PurePred"

From Apache OpenOffice Wiki
Jump to: navigation, search
 
 
(One intermediate revision by one other user not shown)
Line 2: Line 2:
  
 
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.
 
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.
 +
[[Category:Coding Standards]]

Latest revision as of 17:14, 14 December 2009

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.

Personal tools