Skip to content

Inconsistent return value for is_ordered() #2

@spillner

Description

@spillner

The return value convention for is_ordered() is not quite consistent--- if an out-of-order adjacent pair is found, it returns an iterator pointing before the first item in the pair... but on the previous loop iteration (if any) that item was found to be in the proper order relative to its predecessor, so the sequence that ends after this element (i.e. with end iterator ++return_value) is properly ordered, i.e. the return value points before the end of the longest prefix sequence that is well-ordered (or, said another way, points before the first element that is out-of-order relative to its successor, rather than before the first element that is out-of-order relative to its predecessor.) However, if the entire sequence is found to be well-ordered, the past-the-end iterator is returned, i.e. the return value points after (or at) the end of the longest prefix sequence that is well-ordered. Adopting this past-the-end convention for both cases would be more consistent with the STL /and/ let you get rid of the 'next' temporary... which also removes the requirement that the iterator type be assignable.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions