[libc++] basic_string::resize_and_overwrite: Adopt LWG3645 (Not voted in yet)

Adopt LWG3645, which fixes the value categories of basic_string::resize_and_overwrite
https://timsong-cpp.github.io/lwg-issues/3645

Reviewed By: ldionne, #libc

Spies: libcxx-commits

Differential Revision: https://reviews.llvm.org/D116815
This commit is contained in:
Nikolas Klauser 2022-01-20 13:53:59 +01:00
parent 1455eddcf7
commit 4822447522
3 changed files with 5 additions and 3 deletions

View File

@ -137,3 +137,5 @@
`3593 <https://wg21.link/LWG3593>`__,"Several iterators' ``base() const &`` and ``lazy_split_view::outer-iterator::value_type::end()`` missing ``noexcept``","October 2021","","","|ranges|"
`3595 <https://wg21.link/LWG3595>`__,"Exposition-only classes proxy and postfix-proxy for ``common_iterator`` should be fully ``constexpr``","October 2021","","","|ranges|"
"","","","",""
`3645 <https://wg21.link/LWG3645>`__,"``resize_and_overwrite`` is overspecified to call its callback with lvalues", "Not voted in","|Complete|","14.0",""
"","","","",""
Can't render this file because it has a wrong number of fields in line 2.

View File

@ -979,8 +979,7 @@ public:
_LIBCPP_HIDE_FROM_ABI constexpr
void resize_and_overwrite(size_type __n, _Op __op) {
__resize_default_init(__n);
pointer __data = data();
__erase_to_end(_VSTD::move(__op)(__data, __n));
__erase_to_end(_VSTD::move(__op)(data(), _LIBCPP_AUTO_CAST(__n)));
}
#endif

View File

@ -76,7 +76,8 @@ constexpr bool test() {
void test_value_categories() {
std::string s;
s.resize_and_overwrite(10, [](char*&, size_t&) { return 0; });
s.resize_and_overwrite(10, [](char*&&, size_t&&) { return 0; });
s.resize_and_overwrite(10, [](char* const&, const size_t&) { return 0; });
struct RefQualified {
int operator()(char*, size_t) && { return 0; }
};