From 4b9a073780482cb96704035c6f3f11d17dd70123 Mon Sep 17 00:00:00 2001 From: Marshall Clow Date: Sun, 6 Oct 2013 01:24:41 +0000 Subject: [PATCH] Fixed typo in documentation for equal and mismatch; thanks to Larry for the catch [SVN r86171] --- doc/equal.qbk | 2 +- doc/mismatch.qbk | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/equal.qbk b/doc/equal.qbk index 859a8a1..0ba221c 100644 --- a/doc/equal.qbk +++ b/doc/equal.qbk @@ -22,7 +22,7 @@ Consider the two sequences: std::equal ( seq1.begin (), seq1.end (), seq2.begin ()); // true std::equal ( seq2.begin (), seq2.end (), seq1.begin ()); // Undefined behavior - std::equal ( seq1.begin (), seq1.end (), seq1.begin (), seq2.end ()); // false + std::equal ( seq1.begin (), seq1.end (), seq2.begin (), seq2.end ()); // false ``` You can argue that `true` is the correct answer in the first case, even though the sequences are not the same. The first N entries in `seq2` are the same as the entries in `seq1` - but that's not all that's in `seq2`. But in the second case, the algorithm will read past the end of `seq1`, resulting in undefined behavior (large earthquake, incorrect results, pregnant cat, etc). diff --git a/doc/mismatch.qbk b/doc/mismatch.qbk index 630bdc1..cf74293 100644 --- a/doc/mismatch.qbk +++ b/doc/mismatch.qbk @@ -22,7 +22,7 @@ Consider the two sequences: std::mismatch ( seq1.begin (), seq1.end (), seq2.begin ()); // <3, 3> std::mismatch ( seq2.begin (), seq2.end (), seq1.begin ()); // Undefined behavior - std::mismatch ( seq1.begin (), seq1.end (), seq1.begin (), seq2.end ()); // <3, 3> + std::mismatch ( seq1.begin (), seq1.end (), seq2.begin (), seq2.end ()); // <3, 3> ``` The first N entries in `seq2` are the same as the entries in `seq1` - but that's not all that's in `seq2`. In the second case, the algorithm will read past the end of `seq1`, resulting in undefined behavior (large earthquake, incorrect results, pregnant cat, etc).