Jez Higgins

Freelance software generalist
software created
extended or repaired


Older posts are available in the archive or through tags.

Feed

Follow me on Twitter
My code on GitHub

Contact
About

Thursday 03 January 2008 C++: copy_while and copy_until

template<typename InIter, typename OutIter, typename Pred>
OutIter copy_while(InIter first, InIter last, OutIter dest, Pred pred)
{
  for(; first != last && pred(*first); ++first, ++dest)
    *dest = *first;
  return dest;
} // copy_while
template<typename InIter, typename OutIter, typename Pred>
OutIter copy_until(InIter first, InIter last, OutIter dest, Pred pred)
{
  return copy_while(first, last, dest, std::not1(pred));
} // copy_until

For a warm smug feeling, briefly outline possible problems with the above code.


Tagged c++, and code


Jez Higgins

Freelance software generalist
software created
extended or repaired

Older posts are available in the archive or through tags.

Feed

Follow me on Twitter
My code on GitHub

Contact
About