Lecture Notes for CS 509

24 February 2004 - Introduction to Generic Algorithms


replace(b, e, old, new) can be implemented as

while (b != e)
  if (*b == old)
    *b = new
  ++b

The first *b is an r-value start, which means input iterators. The second *b is an l-value *, which means output iterators. The least-powerful iterator category that includes both input and output iterators is forward iterators.


This page last modified on 2 March 2004.