Opened 8 years ago

Last modified 8 years ago

#10483 assigned Bugs

boost::is_sorted docs incorrectly describe predicate

Reported by: charlie@… Owned by: Neil Groves
Milestone: Boost 1.58.0 Component: range
Version: Boost 1.55.0 Severity: Problem
Keywords: Cc:

Description

From the documentation

For the non-predicate version the return value is true if and only if for each adjacent elements [x,y] the expression x < y is true

and similarly for the predicate version. This isn't the case however.

From the standard [alg.sorting]

A sequence is sorted with respect to a comparator comp if for any iterator i pointing to the sequence and any non-negative integer n such that i + n is a valid iterator pointing to an element of the sequence, comp(*(i + n), *i) == false.

So the docs should say

the expression y < x is false

I get the following with g++'s underlying is_sorted():

  std::vector<int> v{1, 1};
  std::cout << boost::is_sorted(v) << std::endl; // prints 1

Reference for is_sorted at cplusplus.com [sorry not allowed to post a link] backs this up.

Change History (1)

comment:1 by Neil Groves, 8 years ago

Milestone: To Be DeterminedBoost 1.58.0
Status: newassigned
Note: See TracTickets for help on using tickets.