[libc++][memory] P2868R1: Removing deprecated typedef std::allocator::is_always_equal (#78562)

Implements:
- https://wg21.link/P2868R1
- https://wg21.link/LWG3170

---------

Co-authored-by: Zingam <zingam@outlook.com>
This commit is contained in:
Hristo Hristov
2024-01-20 06:07:19 +02:00
committed by GitHub
parent b3ea9b398f
commit ed276dff46
10 changed files with 86 additions and 5 deletions

View File

@@ -28,6 +28,7 @@ AttributeMacros: [
'_LIBCPP_DEPRECATED_IN_CXX14',
'_LIBCPP_DEPRECATED_IN_CXX17',
'_LIBCPP_DEPRECATED_IN_CXX20',
'_LIBCPP_DEPRECATED_IN_CXX23',
'_LIBCPP_DEPRECATED',
'_LIBCPP_DISABLE_EXTENTSION_WARNING',
'_LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION',

View File

@@ -59,6 +59,7 @@ Implemented Papers
- P2821R5 - ``span.at()``
- P0521R0 - Proposed Resolution for CA 14 (``shared_ptr`` ``use_count/unique``)
- P1759R6 - Native handles and file streams
- P2868R3 - Remove Deprecated ``std::allocator`` Typedef From C++26
- P2517R1 - Add a conditional ``noexcept`` specification to ``std::apply``
@@ -86,6 +87,9 @@ Improvements and New Features
- The ``_LIBCPP_ENABLE_CXX26_REMOVED_STRING_RESERVE`` macro has been added to make
the function ``std::basic_string<...>::reserve()`` available.
- The ``_LIBCPP_ENABLE_CXX26_REMOVED_ALLOCATOR_MEMBERS`` macro has been added to make
the function ``allocator<T>::is_always_equal`` available.
- The ``_LIBCPP_ENABLE_CXX20_REMOVED_SHARED_PTR_UNIQUE`` macro has been added to make
the function ``std::shared_ptr<...>::unique()`` available.

View File

@@ -15,7 +15,7 @@
"`2743 <https://wg21.link/LWG2743>`__","P0083R3 ``node_handle`` private members missing ""exposition only"" comment","November 2020","|Nothing To Do|",""
"`2820 <https://wg21.link/LWG2820>`__","Clarify ``<cstdint>`` macros","November 2020","|Nothing To Do|",""
"`3120 <https://wg21.link/LWG3120>`__","Unclear behavior of ``monotonic_buffer_resource::release()``","November 2020","",""
"`3170 <https://wg21.link/LWG3170>`__","``is_always_equal`` added to ``std::allocator`` makes the standard library treat derived types as always equal","November 2020","",""
"`3170 <https://wg21.link/LWG3170>`__","``is_always_equal`` added to ``std::allocator`` makes the standard library treat derived types as always equal","November 2020","|Complete|","18.0"
"`3036 <https://wg21.link/LWG3036>`__","``polymorphic_allocator::destroy`` is extraneous","November 2020","",""
"`3171 <https://wg21.link/LWG3171>`__","LWG2989 breaks ``directory_entry`` stream insertion","November 2020","|Complete|","14.0"
"`3306 <https://wg21.link/LWG3306>`__","``ranges::advance`` violates its preconditions","November 2020","|Complete|","14.0","|ranges|"
1 Issue # Issue Name Meeting Status First released version Labels
15 `2743 <https://wg21.link/LWG2743>`__ P0083R3 ``node_handle`` private members missing "exposition only" comment November 2020 |Nothing To Do|
16 `2820 <https://wg21.link/LWG2820>`__ Clarify ``<cstdint>`` macros November 2020 |Nothing To Do|
17 `3120 <https://wg21.link/LWG3120>`__ Unclear behavior of ``monotonic_buffer_resource::release()`` November 2020
18 `3170 <https://wg21.link/LWG3170>`__ ``is_always_equal`` added to ``std::allocator`` makes the standard library treat derived types as always equal November 2020 |Complete| 18.0
19 `3036 <https://wg21.link/LWG3036>`__ ``polymorphic_allocator::destroy`` is extraneous November 2020
20 `3171 <https://wg21.link/LWG3171>`__ LWG2989 breaks ``directory_entry`` stream insertion November 2020 |Complete| 14.0
21 `3306 <https://wg21.link/LWG3306>`__ ``ranges::advance`` violates its preconditions November 2020 |Complete| 14.0 |ranges|

View File

@@ -36,7 +36,7 @@
"`P0952R2 <https://wg21.link/P0952R2>`__","LWG","A new specification for ``std::generate_canonical``","Kona November 2023","","",""
"`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","|Complete|","18.0",""
"`P2868R3 <https://wg21.link/P2868R3>`__","LWG","Remove Deprecated ``std::allocator`` Typedef From C++26","Kona November 2023","","",""
"`P2868R3 <https://wg21.link/P2868R3>`__","LWG","Remove Deprecated ``std::allocator`` Typedef From C++26","Kona November 2023","|Complete|","18.0",""
"`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","","",""
1 Paper # Group Paper Name Meeting Status First released version Labels
36 `P0952R2 <https://wg21.link/P0952R2>`__ LWG A new specification for ``std::generate_canonical`` Kona November 2023
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 |Complete| 18.0
39 `P2868R3 <https://wg21.link/P2868R3>`__ LWG Remove Deprecated ``std::allocator`` Typedef From C++26 Kona November 2023 |Complete| 18.0
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

View File

@@ -283,6 +283,9 @@ C++26 Specific Configuration Macros
This macro is used to re-enable the function
``std::basic_string<...>::reserve()``.
**_LIBCPP_ENABLE_CXX26_REMOVED_ALLOCATOR_MEMBERS**:
This macro is used to re-enable redundant member of ``allocator<T>::is_always_equal``
Libc++ Extensions
=================

View File

@@ -107,7 +107,9 @@ public:
typedef ptrdiff_t difference_type;
typedef _Tp value_type;
typedef true_type propagate_on_container_move_assignment;
typedef true_type is_always_equal;
#if _LIBCPP_STD_VER <= 23 || defined(_LIBCPP_ENABLE_CXX26_REMOVED_ALLOCATOR_MEMBERS)
_LIBCPP_DEPRECATED_IN_CXX23 typedef true_type is_always_equal;
#endif
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 allocator() _NOEXCEPT = default;
@@ -185,7 +187,9 @@ public:
typedef ptrdiff_t difference_type;
typedef const _Tp value_type;
typedef true_type propagate_on_container_move_assignment;
typedef true_type is_always_equal;
#if _LIBCPP_STD_VER <= 23 || defined(_LIBCPP_ENABLE_CXX26_REMOVED_ALLOCATOR_MEMBERS)
_LIBCPP_DEPRECATED_IN_CXX23 typedef true_type is_always_equal;
#endif
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 allocator() _NOEXCEPT = default;

View File

@@ -139,7 +139,7 @@ public:
template <class U> struct rebind {typedef allocator<U> other;}; // deprecated in C++17, removed in C++20
typedef true_type propagate_on_container_move_assignment;
typedef true_type is_always_equal;
typedef true_type is_always_equal; // Deprecated in C++23, removed in C++26
constexpr allocator() noexcept; // constexpr in C++20
constexpr allocator(const allocator&) noexcept; // constexpr in C++20

View File

@@ -0,0 +1,33 @@
//===----------------------------------------------------------------------===//
//
// 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
//
//===----------------------------------------------------------------------===//
// REQUIRES: c++23
// <memory>
// template <class T>
// class allocator
// {
// ...
// typedef true_type is_always_equal; // Deprecated in C++23, removed in C++26
// ...
// };
#include <memory>
void test() {
{
typedef std::allocator<char>::is_always_equal IAE; // expected-warning {{'is_always_equal' is deprecated}}
}
{
typedef std::allocator<const char>::is_always_equal IAE; // expected-warning {{'is_always_equal' is deprecated}}
}
{
typedef std::allocator<void>::is_always_equal IAE; // expected-warning {{'is_always_equal' is deprecated}}
}
}

View File

@@ -46,7 +46,9 @@ void test() {
static_assert((std::is_same<typename Alloc::difference_type, std::ptrdiff_t>::value), "");
static_assert((std::is_same<typename Alloc::value_type, T>::value), "");
static_assert((std::is_same<typename Alloc::propagate_on_container_move_assignment, std::true_type>::value), "");
#if TEST_STD_VER <= 23
static_assert((std::is_same<typename Alloc::is_always_equal, std::true_type>::value), "");
#endif
#if TEST_STD_VER <= 17
static_assert((std::is_same<typename Alloc::pointer, T*>::value), "");

View File

@@ -0,0 +1,34 @@
//===----------------------------------------------------------------------===//
//
// 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
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20, c++23
// <memory>
// Check that the following nested types are removed in C++26:
// template <class T>
// class allocator
// {
// ...
// typedef true_type is_always_equal; // Deprecated in C++23, removed in C++26
// ...
// };
#include <memory>
template <typename T>
void check() {
using IAE = typename std::allocator<T>::is_always_equal; // expected-error 3 {{no type named 'is_always_equal'}}
}
void test() {
check<char>();
check<char const>();
check<void>();
}