[libcxx-commits] [libcxx] d42d9e1 - [libc++] [P0619] Hide not1 and not2 under _LIBCPP_ENABLE_CXX20_REMOVED_NEGATORS.

Arthur O'Dwyer via libcxx-commits libcxx-commits at lists.llvm.org
Tue May 25 13:57:56 PDT 2021


Author: Arthur O'Dwyer
Date: 2021-05-25T16:57:16-04:00
New Revision: d42d9e10b606287f827dcc2d135ff8c932aa3d72

URL: https://github.com/llvm/llvm-project/commit/d42d9e10b606287f827dcc2d135ff8c932aa3d72
DIFF: https://github.com/llvm/llvm-project/commit/d42d9e10b606287f827dcc2d135ff8c932aa3d72.diff

LOG: [libc++] [P0619] Hide not1 and not2 under _LIBCPP_ENABLE_CXX20_REMOVED_NEGATORS.

This also provides some of the scaffolding needed by D102992 and D101729, and mops up after D101730 etc.

Differential Revision: https://reviews.llvm.org/D103055

Added: 
    

Modified: 
    libcxx/docs/Cxx2aStatus.rst
    libcxx/docs/UsingLibcxx.rst
    libcxx/include/__config
    libcxx/include/__memory/raw_storage_iterator.h
    libcxx/include/functional
    libcxx/test/std/utilities/function.objects/negators/binary_negate.depr_in_cxx17.verify.cpp
    libcxx/test/std/utilities/function.objects/negators/binary_negate.pass.cpp
    libcxx/test/std/utilities/function.objects/negators/not1.depr_in_cxx17.verify.cpp
    libcxx/test/std/utilities/function.objects/negators/not1.pass.cpp
    libcxx/test/std/utilities/function.objects/negators/not2.depr_in_cxx17.verify.cpp
    libcxx/test/std/utilities/function.objects/negators/not2.pass.cpp
    libcxx/test/std/utilities/function.objects/negators/unary_negate.depr_in_cxx17.verify.cpp
    libcxx/test/std/utilities/function.objects/negators/unary_negate.pass.cpp
    libcxx/test/std/utilities/memory/storage.iterator/deprecated.verify.cpp
    libcxx/test/std/utilities/memory/storage.iterator/raw_storage_iterator.base.pass.cpp
    libcxx/test/std/utilities/memory/storage.iterator/raw_storage_iterator.pass.cpp

Removed: 
    


################################################################################
diff  --git a/libcxx/docs/Cxx2aStatus.rst b/libcxx/docs/Cxx2aStatus.rst
index ad6713ebc4fea..8346760387fb0 100644
--- a/libcxx/docs/Cxx2aStatus.rst
+++ b/libcxx/docs/Cxx2aStatus.rst
@@ -43,7 +43,7 @@ Paper Status
    .. [#note-P0600] P0600: The missing bits in P0600 are in |sect|\ [mem.res.class], |sect|\ [mem.poly.allocator.class], and |sect|\ [container.node.overview].
    .. [#note-P0966] P0966: It was previously erroneously marked as complete in version 8.0. See `bug 45368 <https://llvm.org/PR45368>`__.
 
-   .. [#note-P0619] P0619: Only ``std::allocator`` part is implemented.
+   .. [#note-P0619] P0619: Only sections D.9 and D.10 are implemented. Section D.8 is partly implemented. Sections D.4, D.7, D.11, D.12, and D.14 remain undone.
 
 
 .. _issues-status-cxx2a:
@@ -56,4 +56,4 @@ Library Working Group Issues Status
    :header-rows: 1
    :widths: auto
 
-Last Updated: 24-Nov-2020
+Last Updated: 24-May-2021

diff  --git a/libcxx/docs/UsingLibcxx.rst b/libcxx/docs/UsingLibcxx.rst
index f146abdf42a53..082eca2b22d24 100644
--- a/libcxx/docs/UsingLibcxx.rst
+++ b/libcxx/docs/UsingLibcxx.rst
@@ -220,12 +220,23 @@ C++17 Specific Configuration Macros
   This macro is used to re-enable all the features removed in C++17. The effect
   is equivalent to manually defining each macro listed below.
 
-**_LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS**:
-  This macro is used to re-enable the `set_unexpected`, `get_unexpected`, and
-  `unexpected` functions, which were removed in C++17.
-
 **_LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR**:
-  This macro is used to re-enable `std::auto_ptr` in C++17.
+  This macro is used to re-enable `auto_ptr`.
+
+**_LIBCPP_ENABLE_CXX17_REMOVED_BINDERS**:
+  This macro is used to re-enable the `binder1st`, `binder2nd`,
+  `pointer_to_unary_function`, `pointer_to_binary_function`, `mem_fun_t`,
+  `mem_fun1_t`, `mem_fun_ref_t`, `mem_fun1_ref_t`, `const_mem_fun_t`,
+  `const_mem_fun1_t`, `const_mem_fun_ref_t`, and `const_mem_fun1_ref_t`
+  class templates, and the `bind1st`, `bind2nd`, `mem_fun`, `mem_fun_ref`,
+  and `ptr_fun` functions.
+
+**_LIBCPP_ENABLE_CXX17_REMOVED_RANDOM_SHUFFLE**:
+  This macro is used to re-enable the `random_shuffle` algorithm.
+
+**_LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS**:
+  This macro is used to re-enable `set_unexpected`, `get_unexpected`, and
+  `unexpected`.
 
 C++20 Specific Configuration Macros:
 ------------------------------------
@@ -234,6 +245,24 @@ C++20 Specific Configuration Macros:
   ``[[nodiscard]]`` in dialects after C++17.  See :ref:`Extended Applications of [[nodiscard]] <nodiscard extension>`
   for more information.
 
+**_LIBCPP_ENABLE_CXX20_REMOVED_FEATURES**:
+  This macro is used to re-enable all the features removed in C++20. The effect
+  is equivalent to manually defining each macro listed below.
+
+**_LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS**:
+  This macro is used to re-enable redundant members of `allocator<T>`,
+  including `pointer`, `reference`, `rebind`, `address`, `max_size`,
+  `construct`, `destroy`, and the two-argument overload of `allocate`.
+  It also re-enables the library-provided explicit specializations
+  of `allocator<void>` and `allocator<const void>`.
+
+**_LIBCPP_ENABLE_CXX20_REMOVED_NEGATORS**:
+  This macro is used to re-enable `not1`, `not2`, `unary_negate`,
+  and `binary_negate`.
+
+**_LIBCPP_ENABLE_CXX20_REMOVED_RAW_STORAGE_ITERATOR**:
+  This macro is used to re-enable `raw_storage_iterator`.
+
 
 Libc++ Extensions
 =================

diff  --git a/libcxx/include/__config b/libcxx/include/__config
index 30a4f4a9527d7..d215fdd078a6b 100644
--- a/libcxx/include/__config
+++ b/libcxx/include/__config
@@ -1363,11 +1363,17 @@ extern "C" _LIBCPP_FUNC_VIS void __sanitizer_annotate_contiguous_container(
 
 #if defined(_LIBCPP_ENABLE_CXX17_REMOVED_FEATURES)
 #define _LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR
-#define _LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS
-#define _LIBCPP_ENABLE_CXX17_REMOVED_RANDOM_SHUFFLE
 #define _LIBCPP_ENABLE_CXX17_REMOVED_BINDERS
+#define _LIBCPP_ENABLE_CXX17_REMOVED_RANDOM_SHUFFLE
+#define _LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS
 #endif // _LIBCPP_ENABLE_CXX17_REMOVED_FEATURES
 
+#if defined(_LIBCPP_ENABLE_CXX20_REMOVED_FEATURES)
+#define _LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS
+#define _LIBCPP_ENABLE_CXX20_REMOVED_NEGATORS
+#define _LIBCPP_ENABLE_CXX20_REMOVED_RAW_STORAGE_ITERATOR
+#endif // _LIBCPP_ENABLE_CXX20_REMOVED_FEATURES
+
 #if !defined(__cpp_deduction_guides) || __cpp_deduction_guides < 201611
 #define _LIBCPP_HAS_NO_DEDUCTION_GUIDES
 #endif

diff  --git a/libcxx/include/__memory/raw_storage_iterator.h b/libcxx/include/__memory/raw_storage_iterator.h
index 529fcd54adaeb..8eed85311b88f 100644
--- a/libcxx/include/__memory/raw_storage_iterator.h
+++ b/libcxx/include/__memory/raw_storage_iterator.h
@@ -25,7 +25,7 @@ _LIBCPP_PUSH_MACROS
 
 _LIBCPP_BEGIN_NAMESPACE_STD
 
-#if _LIBCPP_STD_VER <= 17
+#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_RAW_STORAGE_ITERATOR)
 
 template <class _OutputIterator, class _Tp>
 class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX17 raw_storage_iterator
@@ -54,7 +54,7 @@ class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX17 raw_storage_iterator
 #endif
 };
 
-#endif // _LIBCPP_STD_VER <= 17
+#endif // _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_RAW_STORAGE_ITERATOR)
 
 _LIBCPP_END_NAMESPACE_STD
 

diff  --git a/libcxx/include/functional b/libcxx/include/functional
index 8687ab8f1d8a5..1380c819f908d 100644
--- a/libcxx/include/functional
+++ b/libcxx/include/functional
@@ -192,7 +192,7 @@ struct bit_not : unary_function<T, T>
 struct identity; // C++20
 
 template <class Predicate>
-class unary_negate // deprecated in C++17
+class unary_negate // deprecated in C++17, removed in C++20
     : public unary_function<typename Predicate::argument_type, bool>
 {
 public:
@@ -200,11 +200,11 @@ public:
     bool operator()(const typename Predicate::argument_type& x) const;
 };
 
-template <class Predicate> // deprecated in C++17
+template <class Predicate> // deprecated in C++17, removed in C++20
 unary_negate<Predicate> not1(const Predicate& pred);
 
 template <class Predicate>
-class binary_negate // deprecated in C++17
+class binary_negate // deprecated in C++17, removed in C++20
     : public binary_function<typename Predicate::first_argument_type,
                              typename Predicate::second_argument_type,
                              bool>
@@ -215,7 +215,7 @@ public:
                     const typename Predicate::second_argument_type& y) const;
 };
 
-template <class Predicate> // deprecated in C++17
+template <class Predicate> // deprecated in C++17, removed in C++20
 binary_negate<Predicate> not2(const Predicate& pred);
 
 template <class F>
@@ -1008,6 +1008,7 @@ struct _LIBCPP_TEMPLATE_VIS bit_not<void>
 };
 #endif
 
+#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_NEGATORS)
 template <class _Predicate>
 class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX17 unary_negate
     : public unary_function<typename _Predicate::argument_type, bool>
@@ -1048,6 +1049,7 @@ template <class _Predicate>
 _LIBCPP_DEPRECATED_IN_CXX17 inline _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
 binary_negate<_Predicate>
 not2(const _Predicate& __pred) {return binary_negate<_Predicate>(__pred);}
+#endif // _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_NEGATORS)
 
 #if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_BINDERS)
 template <class __Operation>

diff  --git a/libcxx/test/std/utilities/function.objects/negators/binary_negate.depr_in_cxx17.verify.cpp b/libcxx/test/std/utilities/function.objects/negators/binary_negate.depr_in_cxx17.verify.cpp
index bee130fe8a4e1..50b2f5ad2ab6c 100644
--- a/libcxx/test/std/utilities/function.objects/negators/binary_negate.depr_in_cxx17.verify.cpp
+++ b/libcxx/test/std/utilities/function.objects/negators/binary_negate.depr_in_cxx17.verify.cpp
@@ -13,6 +13,7 @@
 
 // UNSUPPORTED: clang-4.0
 // UNSUPPORTED: c++03, c++11, c++14
+// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_ENABLE_CXX20_REMOVED_NEGATORS
 
 #include <functional>
 

diff  --git a/libcxx/test/std/utilities/function.objects/negators/binary_negate.pass.cpp b/libcxx/test/std/utilities/function.objects/negators/binary_negate.pass.cpp
index 8e310e4887ab2..83ea155b81416 100644
--- a/libcxx/test/std/utilities/function.objects/negators/binary_negate.pass.cpp
+++ b/libcxx/test/std/utilities/function.objects/negators/binary_negate.pass.cpp
@@ -10,6 +10,7 @@
 
 // binary_negate
 
+// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_ENABLE_CXX20_REMOVED_NEGATORS
 // ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DISABLE_DEPRECATION_WARNINGS
 
 #include <functional>

diff  --git a/libcxx/test/std/utilities/function.objects/negators/not1.depr_in_cxx17.verify.cpp b/libcxx/test/std/utilities/function.objects/negators/not1.depr_in_cxx17.verify.cpp
index bc0bdec2561d1..d2fbe3c9e0509 100644
--- a/libcxx/test/std/utilities/function.objects/negators/not1.depr_in_cxx17.verify.cpp
+++ b/libcxx/test/std/utilities/function.objects/negators/not1.depr_in_cxx17.verify.cpp
@@ -13,6 +13,7 @@
 
 // UNSUPPORTED: clang-4.0
 // UNSUPPORTED: c++03, c++11, c++14
+// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_ENABLE_CXX20_REMOVED_NEGATORS
 
 #include <functional>
 

diff  --git a/libcxx/test/std/utilities/function.objects/negators/not1.pass.cpp b/libcxx/test/std/utilities/function.objects/negators/not1.pass.cpp
index f74fb1c4b56d1..638959266e094 100644
--- a/libcxx/test/std/utilities/function.objects/negators/not1.pass.cpp
+++ b/libcxx/test/std/utilities/function.objects/negators/not1.pass.cpp
@@ -10,6 +10,7 @@
 
 // not1
 
+// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_ENABLE_CXX20_REMOVED_NEGATORS
 // ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DISABLE_DEPRECATION_WARNINGS
 
 #include <functional>

diff  --git a/libcxx/test/std/utilities/function.objects/negators/not2.depr_in_cxx17.verify.cpp b/libcxx/test/std/utilities/function.objects/negators/not2.depr_in_cxx17.verify.cpp
index bc00b323d168b..9f7f532ad4ba1 100644
--- a/libcxx/test/std/utilities/function.objects/negators/not2.depr_in_cxx17.verify.cpp
+++ b/libcxx/test/std/utilities/function.objects/negators/not2.depr_in_cxx17.verify.cpp
@@ -13,6 +13,7 @@
 
 // UNSUPPORTED: clang-4.0
 // UNSUPPORTED: c++03, c++11, c++14
+// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_ENABLE_CXX20_REMOVED_NEGATORS
 
 #include <functional>
 

diff  --git a/libcxx/test/std/utilities/function.objects/negators/not2.pass.cpp b/libcxx/test/std/utilities/function.objects/negators/not2.pass.cpp
index 2235b99e10b94..523fcd5e26302 100644
--- a/libcxx/test/std/utilities/function.objects/negators/not2.pass.cpp
+++ b/libcxx/test/std/utilities/function.objects/negators/not2.pass.cpp
@@ -10,6 +10,7 @@
 
 // not2
 
+// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_ENABLE_CXX20_REMOVED_NEGATORS
 // ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DISABLE_DEPRECATION_WARNINGS
 
 #include <functional>

diff  --git a/libcxx/test/std/utilities/function.objects/negators/unary_negate.depr_in_cxx17.verify.cpp b/libcxx/test/std/utilities/function.objects/negators/unary_negate.depr_in_cxx17.verify.cpp
index b98971497c9bc..db29e30ba8cdf 100644
--- a/libcxx/test/std/utilities/function.objects/negators/unary_negate.depr_in_cxx17.verify.cpp
+++ b/libcxx/test/std/utilities/function.objects/negators/unary_negate.depr_in_cxx17.verify.cpp
@@ -13,6 +13,7 @@
 
 // UNSUPPORTED: clang-4.0
 // UNSUPPORTED: c++03, c++11, c++14
+// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_ENABLE_CXX20_REMOVED_NEGATORS
 
 #include <functional>
 

diff  --git a/libcxx/test/std/utilities/function.objects/negators/unary_negate.pass.cpp b/libcxx/test/std/utilities/function.objects/negators/unary_negate.pass.cpp
index de3c42901495d..d3fb9bd089195 100644
--- a/libcxx/test/std/utilities/function.objects/negators/unary_negate.pass.cpp
+++ b/libcxx/test/std/utilities/function.objects/negators/unary_negate.pass.cpp
@@ -10,6 +10,7 @@
 
 // unary_negate
 
+// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_ENABLE_CXX20_REMOVED_NEGATORS
 // ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DISABLE_DEPRECATION_WARNINGS
 
 #include <functional>

diff  --git a/libcxx/test/std/utilities/memory/storage.iterator/deprecated.verify.cpp b/libcxx/test/std/utilities/memory/storage.iterator/deprecated.verify.cpp
index a39f3bae578cb..3ad3cf81bfb86 100644
--- a/libcxx/test/std/utilities/memory/storage.iterator/deprecated.verify.cpp
+++ b/libcxx/test/std/utilities/memory/storage.iterator/deprecated.verify.cpp
@@ -6,7 +6,8 @@
 //
 //===----------------------------------------------------------------------===//
 
-// REQUIRES: c++17
+// UNSUPPORTED: c++03, c++11, c++14
+// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_ENABLE_CXX20_REMOVED_RAW_STORAGE_ITERATOR
 
 // std::raw_storage_iterator
 

diff  --git a/libcxx/test/std/utilities/memory/storage.iterator/raw_storage_iterator.base.pass.cpp b/libcxx/test/std/utilities/memory/storage.iterator/raw_storage_iterator.base.pass.cpp
index 5670e5f957287..996c980824964 100644
--- a/libcxx/test/std/utilities/memory/storage.iterator/raw_storage_iterator.base.pass.cpp
+++ b/libcxx/test/std/utilities/memory/storage.iterator/raw_storage_iterator.base.pass.cpp
@@ -6,12 +6,11 @@
 //
 //===----------------------------------------------------------------------===//
 
-// REQUIRES: c++03 || c++11 || c++14 || c++17
+// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_ENABLE_CXX20_REMOVED_RAW_STORAGE_ITERATOR
+// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DISABLE_DEPRECATION_WARNINGS
 
 // raw_storage_iterator
 
-#define _LIBCPP_DISABLE_DEPRECATION_WARNINGS
-
 #include <memory>
 #include <type_traits>
 #include <cassert>

diff  --git a/libcxx/test/std/utilities/memory/storage.iterator/raw_storage_iterator.pass.cpp b/libcxx/test/std/utilities/memory/storage.iterator/raw_storage_iterator.pass.cpp
index 367482bce5159..33e416bb64f82 100644
--- a/libcxx/test/std/utilities/memory/storage.iterator/raw_storage_iterator.pass.cpp
+++ b/libcxx/test/std/utilities/memory/storage.iterator/raw_storage_iterator.pass.cpp
@@ -6,12 +6,11 @@
 //
 //===----------------------------------------------------------------------===//
 
-// REQUIRES: c++03 || c++11 || c++14 || c++17
+// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_ENABLE_CXX20_REMOVED_RAW_STORAGE_ITERATOR
+// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DISABLE_DEPRECATION_WARNINGS
 
 // raw_storage_iterator
 
-#define _LIBCPP_DISABLE_DEPRECATION_WARNINGS
-
 #include <memory>
 #include <type_traits>
 #include <cassert>


        


More information about the libcxx-commits mailing list