Topic: C++Ox Wish list: mismatch_input


Author: Wil Evers <bouncer@dev.null>
Date: Wed, 3 Jul 2002 17:10:37 GMT
Raw View
Hi,

I'd like to suggest the addition of the following algorithm to the standard
library:

template <typename InputIterator1, typename InputIterator2>
pair<InputIterator1, InputIterator2>
mismatch_input(InputIterator1 first1, InputIterator1 last1,
        InputIterator2 first2, InputIterator2 last2)
{
        while (first1 != last1 && first2 != last2 &&
                *first1 == *first2) {
                ++first1;
                ++first2;
        }
        return make_pair(first1, first2);
}

- plus a variant taking a BinaryPredicate.

I've repeatedly run into a situation where I need to test two ranges for
equality, and it's either impossible or undesirable to first determine
which one is the shortest.

Am I missing something, or is the really no such algorithm in the current
standard library?

- Wil

--
Wil Evers, DOOSYS R&D BV, Utrecht, Holland
[Wil underscore Evers at doosys dot com]

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html                       ]