[libc++] Do not require movability in __non_propagating_cache::__emplace_deref
authorLouis Dionne <ldionne.2@gmail.com>
Wed, 11 Aug 2021 18:26:33 +0000 (14:26 -0400)
committerLouis Dionne <ldionne.2@gmail.com>
Tue, 17 Aug 2021 15:32:40 +0000 (11:32 -0400)
commitceff0b7258aefc6e5299802c119b3d01545440f4
tree256d94c6d394726dacdde4049b3059e204d73cf3
parentad40cb8821666a255ad9982b99ea0ce13a57dfaa
[libc++] Do not require movability in __non_propagating_cache::__emplace_deref

As explained in http://eel.is/c++draft/range.nonprop.cache#note-1, we
should allow copy and move elision to happen when calling emplace_deref
in non-propagating-cache. Before this change, the only way to emplace
into the non-propagating-cache was to call `__set(*it)`, which materialized
`*it` when binding it to the reference argument of `__set` and disabled
move elision.

As a fly-by change, this also renames `__set` to `__emplace` for consistency
and adds tests for it.

Differential Revision: https://reviews.llvm.org/D107932
12 files changed:
libcxx/include/__ranges/drop_view.h
libcxx/include/__ranges/join_view.h
libcxx/include/__ranges/non_propagating_cache.h
libcxx/include/__ranges/reverse_view.h
libcxx/test/libcxx/ranges/range.nonprop.cache/assign.copy.pass.cpp
libcxx/test/libcxx/ranges/range.nonprop.cache/assign.move.pass.cpp
libcxx/test/libcxx/ranges/range.nonprop.cache/ctor.copy.pass.cpp
libcxx/test/libcxx/ranges/range.nonprop.cache/ctor.move.pass.cpp
libcxx/test/libcxx/ranges/range.nonprop.cache/deref.pass.cpp
libcxx/test/libcxx/ranges/range.nonprop.cache/emplace.pass.cpp [new file with mode: 0644]
libcxx/test/libcxx/ranges/range.nonprop.cache/emplace_from.pass.cpp [new file with mode: 0644]
libcxx/test/libcxx/ranges/range.nonprop.cache/has_value.pass.cpp