[libc++] Removes basic_string::reserve(). (#73354)

Implements:
- P2870R3 Remove basic_string::reserve()

---------

Co-authored-by: philnik777 <nikolasklauser@berlin.de>
This commit is contained in:
Mark de Wever 2023-11-25 13:56:40 +01:00 committed by GitHub
parent 84a20989c6
commit 494c9e5f59
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 35 additions and 6 deletions

View File

@ -52,6 +52,7 @@ Implemented Papers
- P0020R6 - Floating Point Atomic
- P2918R2 - Runtime format strings II
- P2871R3 - Remove Deprecated Unicode Conversion Facets from C++26
- P2870R3 - Remove basic_string::reserve()
Improvements and New Features
@ -75,6 +76,9 @@ Improvements and New Features
- The ``_LIBCPP_ENABLE_CXX26_REMOVED_CODECVT`` macro has been added to make
the declarations in ``<codecvt>`` available.
- The ``_LIBCPP_ENABLE_CXX26_REMOVED_STRING_RESERVE`` macro has been added to make
the function ``std::basic_string<...>::reserve()`` available.
Deprecations and Removals
-------------------------

View File

@ -37,7 +37,7 @@
"`P2447R6 <https://wg21.link/P2447R6>`__","LWG","``std::span`` over an initializer list","Kona November 2023","","",""
"`P2821R5 <https://wg21.link/P2821R5>`__","LWG","``span.at()``","Kona November 2023","","",""
"`P2868R3 <https://wg21.link/P2868R3>`__","LWG","Remove Deprecated ``std::allocator`` Typedef From C++26","Kona November 2023","","",""
"`P2870R3 <https://wg21.link/P2870R3>`__","LWG","Remove ``basic_string::reserve()`` From C++26","Kona November 2023","","",""
"`P2870R3 <https://wg21.link/P2870R3>`__","LWG","Remove ``basic_string::reserve()`` From C++26","Kona November 2023","|Complete|","18.0",""
"`P2871R3 <https://wg21.link/P2871R3>`__","LWG","Remove Deprecated Unicode Conversion Facets from C++26","Kona November 2023","|Complete|","18.0",""
"`P2819R2 <https://wg21.link/P2819R2>`__","LWG","Add tuple protocol to complex","Kona November 2023","","",""
"`P2937R0 <https://wg21.link/P2937R0>`__","LWG","Freestanding: Remove ``strtok``","Kona November 2023","","",""

1 Paper # Group Paper Name Meeting Status First released version Labels
37 `P2447R6 <https://wg21.link/P2447R6>`__ LWG ``std::span`` over an initializer list Kona November 2023
38 `P2821R5 <https://wg21.link/P2821R5>`__ LWG ``span.at()`` Kona November 2023
39 `P2868R3 <https://wg21.link/P2868R3>`__ LWG Remove Deprecated ``std::allocator`` Typedef From C++26 Kona November 2023
40 `P2870R3 <https://wg21.link/P2870R3>`__ LWG Remove ``basic_string::reserve()`` From C++26 Kona November 2023 |Complete| 18.0
41 `P2871R3 <https://wg21.link/P2871R3>`__ LWG Remove Deprecated Unicode Conversion Facets from C++26 Kona November 2023 |Complete| 18.0
42 `P2819R2 <https://wg21.link/P2819R2>`__ LWG Add tuple protocol to complex Kona November 2023
43 `P2937R0 <https://wg21.link/P2937R0>`__ LWG Freestanding: Remove ``strtok`` Kona November 2023

View File

@ -335,6 +335,9 @@ C++26 Specific Configuration Macros
**_LIBCPP_ENABLE_CXX26_REMOVED_CODECVT**:
This macro is used to re-enable all named declarations in ``<codecvt>``.
**_LIBCPP_ENABLE_CXX26_REMOVED_STRING_RESERVE**
This macro is used to re-enable the function
``std::basic_string<...>::reserve()``.
Libc++ Extensions
=================

View File

@ -173,7 +173,7 @@ public:
constexpr void resize_and_overwrite(size_type n, Operation op); // since C++23
void reserve(size_type res_arg); // constexpr since C++20
void reserve(); // deprecated in C++20
void reserve(); // deprecated in C++20, removed in C++26
void shrink_to_fit(); // constexpr since C++20
void clear() noexcept; // constexpr since C++20
bool empty() const noexcept; // constexpr since C++20
@ -1187,7 +1187,9 @@ public:
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __resize_default_init(size_type __n);
#if _LIBCPP_STD_VER < 26 || defined(_LIBCPP_ENABLE_CXX26_REMOVED_STRING_RESERVE)
_LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_HIDE_FROM_ABI void reserve() _NOEXCEPT { shrink_to_fit(); }
#endif
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void shrink_to_fit() _NOEXCEPT;
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void clear() _NOEXCEPT;

View File

@ -11,7 +11,7 @@
// void reserve(); // Deprecated in C++20.
// void reserve(size_type);
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DISABLE_DEPRECATION_WARNINGS
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DISABLE_DEPRECATION_WARNINGS -D_LIBCPP_ENABLE_CXX26_REMOVED_STRING_RESERVE
// This test ensures that libc++ implements https://wg21.link/P0966R1 (reserve never shrinks)
// even before C++20. This is required in order to avoid ODR violations because basic_string::reserve(size)

View File

@ -10,7 +10,7 @@
// void reserve(); // Deprecated in C++20
// UNSUPPORTED: c++03, c++11, c++14, c++17
// UNSUPPORTED: c++03, c++11, c++14, c++17, c++26
#include <string>

View File

@ -8,9 +8,9 @@
// <string>
// void reserve(); // Deprecated in C++20.
// void reserve(); // Deprecated in C++20, removed in C++26.
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DISABLE_DEPRECATION_WARNINGS
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DISABLE_DEPRECATION_WARNINGS -D_LIBCPP_ENABLE_CXX26_REMOVED_STRING_RESERVE
#include <string>
#include <stdexcept>

View File

@ -0,0 +1,20 @@
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// <string>
// void reserve(); // Removed in C++26
// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20, c++23
#include <string>
void f() {
std::string s;
s.reserve(); // expected-error {{too few arguments to function call}}
}