C++ 入门(第 5 版);第 19 章 - 算法:std::lower_bound

C++ Primer (5th edition); Ch 19 - Algorithms: std::lower_bound

本文来自C++ Primer(第5th版);第 19 章“附录:算法”:

lower_bound(beg, end, val)
lower_bound(beg, end, val, comp)

Returns an iterator denoting the first element such that val is not less than that element, or end if no such element exists.

upper_bound(beg, end, val)
upper_bound(beg, end, val, comp)

Returns an iterator denoting the first element

Is it a mistake in the book?

如果您信任cppreference,那么:是的,这是一个错误:

std::lower_bound

Returns an iterator pointing to the first element in the range [first, last) that is not less than (i.e. greater or equal to) value, or last if no such element is found.

或者,如果您信任该网站,this Draft C++17 Standard有:

28.7.3.1 lower_bound       [lower.bound]



2     Returns: The furthermost iterator i in the range [first, last] such that for every iterator j in the range [first, i) the following corresponding conditions hold: *j < value or comp(*j, value) != false.

this (later) online Draft Standard 中,它是 §25.8.4.2