Subject: Re: [Boost-bugs] [Boost C++ Libraries] #13383: Doc for is_sorted() incorrectly states the predicate defaults to std::less_equal (was: is_sorted() doc incorrectly says the predicate defaults to std::less_equal)
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2018-01-09 11:50:46
#13383: Doc for is_sorted() incorrectly states the predicate defaults to
std::less_equal
-------------------------------------+-------------------------------------
Reporter: Tony Lewis | Owner: Marshall Clow
<tonyelewis@â¦> |
Type: Bugs | Status: new
Milestone: To Be Determined | Component: algorithm
Version: Boost Development | Severity: Problem
Trunk | Keywords:
Resolution: | predicate,is_sorted,algorithm,less,less_equal
-------------------------------------+-------------------------------------
Changes (by Tony Lewis <tonyelewis@â¦>):
* keywords: => predicate,is_sorted,algorithm,less,less_equal
* owner: (none) => Marshall Clow
* version: Boost 1.63.0 => Boost Development Trunk
* component: None => algorithm
Comment:
(Apologies for the description at the top being a mess. My original
submission had external links in and I was forced to do a captcha. That
failed over and over until I ended up trying to use browser "back" and
"reload" to try to recover my original submission and eventually found I'd
submitted an early draft.)
Second, terser version of lost text...
Doc for `is_sorted()` says:
> If no comparison predicate is specified, then std::less_equal is used
(i.e, the test is to see if the sequence is non-decreasing)
That's not true, it's `std::less` - see line 60 of
`boost/algorithm/cxx11/is_sorted.hpp`.
This code confirms the default behaviour matches `std::less` not
`std::less_equal`.
{{{
#cpp
int main () {
std::vector<int> a = { 1, 2, 2, 3 };
std::cerr << "default : " << std::boolalpha <<
boost::algorithm::is_sorted( a ) << "\n";
std::cerr << "less : " << std::boolalpha <<
boost::algorithm::is_sorted( a, std::less <>{} ) << "\n";
std::cerr << "less_equal: " << std::boolalpha <<
boost::algorithm::is_sorted( a, std::less_equal<>{} ) << "\n";
}
}}}
I vote: change docs, not code. Because: that matches `std::`.
-- Ticket URL: <https://svn.boost.org/trac10/boost/ticket/13383#comment:1> Boost C++ Libraries <http://www.boost.org/> Boost provides free peer-reviewed portable C++ source libraries.
This archive was generated by hypermail 2.1.7 : 2018-01-09 11:58:04 UTC