Boost logo

Boost :

Subject: [boost] [algorithm] documentation mistakes in 'equal' and 'mismatch'
From: Takatoshi Kondo (redboltz_at_[hidden])
Date: 2013-10-06 07:29:31


Hi, Marshall

IIUC, I found some mistakes in the documentation of 'equal' and 'mismatch'.

http://www.boost.org/doc/libs/1_54_0/libs/algorithm/doc/html/algorithm/CXX14.html#the_boost_algorithm_library.CXX14.equal
http://www.boost.org/doc/libs/1_54_0/libs/algorithm/doc/html/the_boost_algorithm_library/CXX14/mismatch.html

In the first code block,

auto seq1 = { 0, 1, 2 };
auto seq2 = { 0, 1, 2, 3, 4 };

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

The second seq1.begin() in the last line should be seq2.begin() as follows.

std::equal ( seq1.begin (), seq1.end (), seq2.begin (), seq2.end ()); // false

Similarly,

std::mismatch ( seq1.begin (), seq1.end (), seq1.begin (), seq2.end
()); // <3, 3>

should be

std::mismatch ( seq1.begin (), seq1.end (), seq2.begin (), seq2.end
()); // <3, 3>

Thanks,
Takatoshi


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk