1. template <class InputIterator1, class InputIterator2, class BinaryPredicate> 
  2. pair<InputIterator1, InputIterator2> mismatch(InputIterator1 first1, 
  3.                                         InputIterator1 last1, 
  4.                                         InputIterator2 first2, 
  5.                                         InputIterator2 last2 
  6.                                         BinaryPredicate binary_pred) { 
  7.     while(first1 != last1 && binary_pred(*first1, *first2)) { 
  8.         ++first1; 
  9.         ++first2; 
  10.     } 
  11.     return pair<InputIterator1, InputIterator2>(first1, first2); 

    从上述代码可以看出,mismatch函数默认第一个匹配区间的长度要大于第二个匹配区间,所以在调用该函数时需要多加注意,否则行为将不可预测。