-
Notifications
You must be signed in to change notification settings - Fork 117
Closed
Description
Following on from Trac#13383…
Docs for is_sorted()
currently say:
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)
…but that's not true—it defaults to 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
.
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 the docs, not the code, because the code matches std::
. I'm happy to submit a PR for this - please shout if I should do that.
Metadata
Metadata
Assignees
Labels
No labels