Специализни шаблонца! (udpn) wrote,
Специализни шаблонца!
udpn

What do I do when there's no STL algorithm I need


  1. template <class NeedleIterator, class HaystackIterator>

  2. bool equals_zip(

  3.  NeedleIterator needle_begin, NeedleIterator needle_end,

  4.  HaystackIterator haystack_begin, HaystackIterator haystack_end

  5. ) {

  6.  while (needle_begin != needle_end) {

  7.    if (haystack_begin == haystack_end)

  8.      return false;

  9.    if (!(*needle_begin == *haystack_begin))

  10.      return false;

  11.    ++needle_begin;

  12.    ++haystack_begin;

  13.  }

  14.  return true;

  15. }

Subscribe
  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 5 comments