[libc++] Fix `_IterOps::__iter_move` to support proxy iterators.
authorKonstantin Varlamov <varconst@apple.com>
Wed, 20 Jul 2022 20:17:25 +0000 (13:17 -0700)
committerKonstantin Varlamov <varconst@apple.com>
Wed, 20 Jul 2022 20:19:00 +0000 (13:19 -0700)
commitbc4d2e70518476f0a445761d43fee8b9e6670368
tree3a487e0c0c780179d00170eee5414461c3149809
parent2ac7b142b12f66ce91c98177f8d7d942ed4cc94c
[libc++] Fix `_IterOps::__iter_move` to support proxy iterators.

The return type was specified incorrectly for proxy iterators that
define `reference` to be a class that implicitly converts to
`value_type`. `__iter_move` would end up returning an object of type
`reference` which would then implicitly convert to `value_type`; thus,
the function will return a `value_type&&` rvalue reference to the local
temporary.

Differential Revision: https://reviews.llvm.org/D130197
libcxx/include/__algorithm/iterator_operations.h
libcxx/test/std/algorithms/alg.sorting/alg.sort/sort/sort_proxy.pass.cpp [new file with mode: 0644]