Why the sequence-operation algorithms predicates are passed by copy?

It’s mostly for historic reasons. At ’98 when the whole algo stuff made it into the standard references had all kind of problems. That got eventually resolved through core and library DRs by C++03 and beyond. Also sensible ref-wrappers and actually working bind only arrived only in TR1.

Those who tried use algos with early C++98 having functions using ref params or returns can recall all kind of trouble. Self-written algos were also prone to hit the dreaded ‘reference to reference’ problem.

Passing by value at least worked fine, and hardly created many problems — and boost had ref and cref early on to help out where you needed to tweak.

Leave a Comment