This is an archive of the discontinued LLVM Phabricator instance.

[libc++][ranges] Fix the return value of `{copy,move}_backward`.
ClosedPublic

Authored by var-const on Aug 2 2022, 12:59 AM.

Details

Summary

The return value for both of these algorithms is specified as

`{last, result - N}` for the overloads in namespace `ranges`.

But the current implementation instead returns {first, result - N}.

Also add both algorithms to the relevant "robust" tests.

Diff Detail

Event Timeline

var-const created this revision.Aug 2 2022, 12:59 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 2 2022, 12:59 AM
var-const requested review of this revision.Aug 2 2022, 12:59 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 2 2022, 12:59 AM
Herald added a reviewer: Restricted Project. · View Herald Transcript
philnik accepted this revision.Aug 2 2022, 2:54 AM

LGTM % nit.

libcxx/include/__algorithm/ranges_move_backward.h
44–45

Pre-existing: Could you make copy and move consistent w.r.t. using __reverse_range?

This revision is now accepted and ready to land.Aug 2 2022, 2:54 AM
ldionne accepted this revision.Aug 2 2022, 3:30 PM
ldionne added inline comments.
libcxx/include/__algorithm/ranges_move_backward.h
44–45

I'm neutral on this given that we're about to refactor these algorithms significantly to remove their dependency on reverse_iterator altogether.

var-const marked 2 inline comments as done.Aug 2 2022, 10:22 PM
var-const added inline comments.
libcxx/include/__algorithm/ranges_move_backward.h
44–45

I'm inclined to leave as is for the reason that @ldionne mentioned (though I agree it's a good idea).

This revision was automatically updated to reflect the committed changes.
var-const marked an inline comment as done.