[libcxx-commits] [libcxx] 9e5c293 - [libc++] Removes __cpp_lib_monadic_optional.

Mark de Wever via libcxx-commits libcxx-commits at lists.llvm.org
Tue May 31 10:18:42 PDT 2022


Author: Mark de Wever
Date: 2022-05-31T19:18:34+02:00
New Revision: 9e5c293492a779497227b9fff3ee4afae85fe2e4

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

LOG: [libc++] Removes __cpp_lib_monadic_optional.

P0798R8 "Monadic operations for std::optional" has been implemented, so
this LWG issue can be adopted.

During review it was discovered another paper bumped the macro. The
part affecting optional of this paper is done, the variant isn't. The
status page is updated to reflect the current state.

Implements
- LWG 3621 Remove feature-test macro __cpp_lib_monadic_optional

Updates status of
- P2231R1 Missing constexpr in std::optional and std::variant

Reviewed By: #libc, philnik, ldionne

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

Added: 
    

Modified: 
    libcxx/docs/FeatureTestMacroTable.rst
    libcxx/docs/Status/Cxx20.rst
    libcxx/docs/Status/Cxx20Papers.csv
    libcxx/docs/Status/Cxx2bIssues.csv
    libcxx/include/optional
    libcxx/include/version
    libcxx/test/std/language.support/support.limits/support.limits.general/optional.version.compile.pass.cpp
    libcxx/test/std/language.support/support.limits/support.limits.general/version.version.compile.pass.cpp
    libcxx/utils/generate_feature_test_macro_components.py

Removed: 
    


################################################################################
diff  --git a/libcxx/docs/FeatureTestMacroTable.rst b/libcxx/docs/FeatureTestMacroTable.rst
index 5d82ad26aca73..481507750b735 100644
--- a/libcxx/docs/FeatureTestMacroTable.rst
+++ b/libcxx/docs/FeatureTestMacroTable.rst
@@ -316,10 +316,10 @@ Status
     ------------------------------------------------- -----------------
     ``__cpp_lib_is_scoped_enum``                      ``202011L``
     ------------------------------------------------- -----------------
-    ``__cpp_lib_monadic_optional``                    ``202110L``
-    ------------------------------------------------- -----------------
     ``__cpp_lib_move_only_function``                  *unimplemented*
     ------------------------------------------------- -----------------
+    ``__cpp_lib_optional``                            ``202110L``
+    ------------------------------------------------- -----------------
     ``__cpp_lib_out_ptr``                             *unimplemented*
     ------------------------------------------------- -----------------
     ``__cpp_lib_ranges_chunk``                        *unimplemented*

diff  --git a/libcxx/docs/Status/Cxx20.rst b/libcxx/docs/Status/Cxx20.rst
index 3872308e85773..a4d9b03e10e0c 100644
--- a/libcxx/docs/Status/Cxx20.rst
+++ b/libcxx/docs/Status/Cxx20.rst
@@ -47,6 +47,7 @@ Paper Status
    .. [#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 sections D.8, D.9, D.10 and D.13 are implemented. Sections D.4, D.7, D.11, D.12, and D.14 remain undone.
    .. [#note-P0883] P0883: shared_ptr and floating-point changes weren't applied as they themselves aren't implemented yet.
+   .. [#note-P2231] P2231: Optional is complete. The changes to variant haven't been implemented yet.
 
 
 .. _issues-status-cxx20:

diff  --git a/libcxx/docs/Status/Cxx20Papers.csv b/libcxx/docs/Status/Cxx20Papers.csv
index b887d3d9f180c..2a00accf35907 100644
--- a/libcxx/docs/Status/Cxx20Papers.csv
+++ b/libcxx/docs/Status/Cxx20Papers.csv
@@ -193,7 +193,7 @@
 "`P2106R0 <https://wg21.link/P2106R0>`__","LWG","Alternative wording for GB315 and GB316","Prague","* *",""
 "`P2116R0 <https://wg21.link/P2116R0>`__","LWG","Remove tuple-like protocol support from fixed-extent span","Prague","|Complete|","11.0"
 "","","","","",""
-"`P2231R1 <https://wg21.link/P2231R1>`__","LWG","Missing constexpr in std::optional and std::variant","June 2021","|In progress|","13.0"
+"`P2231R1 <https://wg21.link/P2231R1>`__","LWG","Missing constexpr in std::optional and std::variant","June 2021","|Partial| [#note-P2231]_","13.0"
 "`P2325R3 <https://wg21.link/P2325R3>`__","LWG","Views should not be required to be default constructible","June 2021","|In progress|",""
 "`P2210R2 <https://wg21.link/P2210R2>`__","LWG",Superior String Splitting,"June 2021","",""
 "`P2216R3 <https://wg21.link/P2216R3>`__","LWG",std::format improvements,"June 2021","|Partial|",""

diff  --git a/libcxx/docs/Status/Cxx2bIssues.csv b/libcxx/docs/Status/Cxx2bIssues.csv
index 93fa19d6cdf7c..a406edb04a8b2 100644
--- a/libcxx/docs/Status/Cxx2bIssues.csv
+++ b/libcxx/docs/Status/Cxx2bIssues.csv
@@ -148,7 +148,7 @@
 "`3616 <https://wg21.link/LWG3616>`__","LWG 3498 seems to miss the non-member ``swap`` for ``basic_syncbuf`` ","February 2022","",""
 "`3618 <https://wg21.link/LWG3618>`__","Unnecessary ``iter_move`` for ``transform_view::iterator`` ","February 2022","","","|ranges|"
 "`3619 <https://wg21.link/LWG3619>`__","Specification of ``vformat_to`` contains ill-formed ``formatted_size`` calls","February 2022","|Nothing to do|","","|format|"
-"`3621 <https://wg21.link/LWG3621>`__","Remove feature-test macro ``__cpp_lib_monadic_optional`` ","February 2022","",""
+"`3621 <https://wg21.link/LWG3621>`__","Remove feature-test macro ``__cpp_lib_monadic_optional`` ","February 2022","|Complete|","15.0"
 "`3632 <https://wg21.link/LWG3632>`__","``unique_ptr`` ""Mandates: This constructor is not selected by class template argument deduction""","February 2022","|Nothing to do|",""
 "`3643 <https://wg21.link/LWG3643>`__","Missing ``constexpr`` in ``std::counted_iterator`` ","February 2022","",""
 "`3648 <https://wg21.link/LWG3648>`__","``format`` should not print ``bool`` with ``'c'`` ","February 2022","|Complete|","15.0","|format|"

diff  --git a/libcxx/include/optional b/libcxx/include/optional
index 3b716e2e5c118..ed6ce9fc07977 100644
--- a/libcxx/include/optional
+++ b/libcxx/include/optional
@@ -93,11 +93,11 @@ namespace std {
     template <class U, class... Args>
       constexpr explicit optional(in_place_t, initializer_list<U>, Args &&...);
     template <class U = T>
-      constexpr EXPLICIT optional(U &&);
+      constexpr explicit(see-below) optional(U &&);
     template <class U>
-      EXPLICIT optional(const optional<U> &);   // constexpr in C++20
+      explicit(see-below) optional(const optional<U> &);         // constexpr in C++20
     template <class U>
-      EXPLICIT optional(optional<U> &&);        // constexpr in C++20
+      explicit(see-below) optional(optional<U> &&);              // constexpr in C++20
 
     // 23.6.3.2, destructor
     ~optional(); // constexpr in C++20

diff  --git a/libcxx/include/version b/libcxx/include/version
index 95b863cbdd9af..59c955a672ace 100644
--- a/libcxx/include/version
+++ b/libcxx/include/version
@@ -117,7 +117,6 @@ __cpp_lib_map_try_emplace                               201411L <map>
 __cpp_lib_math_constants                                201907L <numbers>
 __cpp_lib_math_special_functions                        201603L <cmath>
 __cpp_lib_memory_resource                               201603L <memory_resource>
-__cpp_lib_monadic_optional                              202110L <optional>
 __cpp_lib_move_only_function                            202110L <functional>
 __cpp_lib_node_extract                                  201606L <map> <set> <unordered_map>
                                                                 <unordered_set>
@@ -127,7 +126,8 @@ __cpp_lib_nonmember_container_access                    201411L <array> <deque>
                                                                 <unordered_map> <unordered_set> <vector>
 __cpp_lib_not_fn                                        201603L <functional>
 __cpp_lib_null_iterators                                201304L <iterator>
-__cpp_lib_optional                                      201606L <optional>
+__cpp_lib_optional                                      202110L <optional>
+                                                        201606L // C++17
 __cpp_lib_out_ptr                                       202106L <memory>
 __cpp_lib_parallel_algorithm                            201603L <algorithm> <numeric>
 __cpp_lib_polymorphic_allocator                         201902L <memory_resource>
@@ -382,8 +382,9 @@ __cpp_lib_void_t                                        201411L <type_traits>
 // # define __cpp_lib_constexpr_typeinfo                   202106L
 // # define __cpp_lib_invoke_r                             202106L
 # define __cpp_lib_is_scoped_enum                       202011L
-# define __cpp_lib_monadic_optional                     202110L
 // # define __cpp_lib_move_only_function                   202110L
+# undef  __cpp_lib_optional
+# define __cpp_lib_optional                             202110L
 // # define __cpp_lib_out_ptr                              202106L
 // # define __cpp_lib_ranges_chunk                         202202L
 // # define __cpp_lib_ranges_chunk_by                      202202L

diff  --git a/libcxx/test/std/language.support/support.limits/support.limits.general/optional.version.compile.pass.cpp b/libcxx/test/std/language.support/support.limits/support.limits.general/optional.version.compile.pass.cpp
index 4688db7c70079..b1c5f3126eaea 100644
--- a/libcxx/test/std/language.support/support.limits/support.limits.general/optional.version.compile.pass.cpp
+++ b/libcxx/test/std/language.support/support.limits/support.limits.general/optional.version.compile.pass.cpp
@@ -15,9 +15,9 @@
 
 // Test the feature test macros defined by <optional>
 
-/*  Constant                      Value
-    __cpp_lib_monadic_optional    202110L [C++2b]
-    __cpp_lib_optional            201606L [C++17]
+/*  Constant              Value
+    __cpp_lib_optional    201606L [C++17]
+                          202110L [C++2b]
 */
 
 #include <optional>
@@ -25,30 +25,18 @@
 
 #if TEST_STD_VER < 14
 
-# ifdef __cpp_lib_monadic_optional
-#   error "__cpp_lib_monadic_optional should not be defined before c++2b"
-# endif
-
 # ifdef __cpp_lib_optional
 #   error "__cpp_lib_optional should not be defined before c++17"
 # endif
 
 #elif TEST_STD_VER == 14
 
-# ifdef __cpp_lib_monadic_optional
-#   error "__cpp_lib_monadic_optional should not be defined before c++2b"
-# endif
-
 # ifdef __cpp_lib_optional
 #   error "__cpp_lib_optional should not be defined before c++17"
 # endif
 
 #elif TEST_STD_VER == 17
 
-# ifdef __cpp_lib_monadic_optional
-#   error "__cpp_lib_monadic_optional should not be defined before c++2b"
-# endif
-
 # ifndef __cpp_lib_optional
 #   error "__cpp_lib_optional should be defined in c++17"
 # endif
@@ -58,10 +46,6 @@
 
 #elif TEST_STD_VER == 20
 
-# ifdef __cpp_lib_monadic_optional
-#   error "__cpp_lib_monadic_optional should not be defined before c++2b"
-# endif
-
 # ifndef __cpp_lib_optional
 #   error "__cpp_lib_optional should be defined in c++20"
 # endif
@@ -71,18 +55,11 @@
 
 #elif TEST_STD_VER > 20
 
-# ifndef __cpp_lib_monadic_optional
-#   error "__cpp_lib_monadic_optional should be defined in c++2b"
-# endif
-# if __cpp_lib_monadic_optional != 202110L
-#   error "__cpp_lib_monadic_optional should have the value 202110L in c++2b"
-# endif
-
 # ifndef __cpp_lib_optional
 #   error "__cpp_lib_optional should be defined in c++2b"
 # endif
-# if __cpp_lib_optional != 201606L
-#   error "__cpp_lib_optional should have the value 201606L in c++2b"
+# if __cpp_lib_optional != 202110L
+#   error "__cpp_lib_optional should have the value 202110L in c++2b"
 # endif
 
 #endif // TEST_STD_VER > 20

diff  --git a/libcxx/test/std/language.support/support.limits/support.limits.general/version.version.compile.pass.cpp b/libcxx/test/std/language.support/support.limits/support.limits.general/version.version.compile.pass.cpp
index e51624fbf7901..9c6697ceb4e0f 100644
--- a/libcxx/test/std/language.support/support.limits/support.limits.general/version.version.compile.pass.cpp
+++ b/libcxx/test/std/language.support/support.limits/support.limits.general/version.version.compile.pass.cpp
@@ -111,13 +111,13 @@
     __cpp_lib_math_constants                       201907L [C++20]
     __cpp_lib_math_special_functions               201603L [C++17]
     __cpp_lib_memory_resource                      201603L [C++17]
-    __cpp_lib_monadic_optional                     202110L [C++2b]
     __cpp_lib_move_only_function                   202110L [C++2b]
     __cpp_lib_node_extract                         201606L [C++17]
     __cpp_lib_nonmember_container_access           201411L [C++17]
     __cpp_lib_not_fn                               201603L [C++17]
     __cpp_lib_null_iterators                       201304L [C++14]
     __cpp_lib_optional                             201606L [C++17]
+                                                   202110L [C++2b]
     __cpp_lib_out_ptr                              202106L [C++2b]
     __cpp_lib_parallel_algorithm                   201603L [C++17]
     __cpp_lib_polymorphic_allocator                201902L [C++20]
@@ -556,10 +556,6 @@
 #   error "__cpp_lib_memory_resource should not be defined before c++17"
 # endif
 
-# ifdef __cpp_lib_monadic_optional
-#   error "__cpp_lib_monadic_optional should not be defined before c++2b"
-# endif
-
 # ifdef __cpp_lib_move_only_function
 #   error "__cpp_lib_move_only_function should not be defined before c++2b"
 # endif
@@ -1212,10 +1208,6 @@
 #   error "__cpp_lib_memory_resource should not be defined before c++17"
 # endif
 
-# ifdef __cpp_lib_monadic_optional
-#   error "__cpp_lib_monadic_optional should not be defined before c++2b"
-# endif
-
 # ifdef __cpp_lib_move_only_function
 #   error "__cpp_lib_move_only_function should not be defined before c++2b"
 # endif
@@ -2030,10 +2022,6 @@
 #   endif
 # endif
 
-# ifdef __cpp_lib_monadic_optional
-#   error "__cpp_lib_monadic_optional should not be defined before c++2b"
-# endif
-
 # ifdef __cpp_lib_move_only_function
 #   error "__cpp_lib_move_only_function should not be defined before c++2b"
 # endif
@@ -3142,10 +3130,6 @@
 #   endif
 # endif
 
-# ifdef __cpp_lib_monadic_optional
-#   error "__cpp_lib_monadic_optional should not be defined before c++2b"
-# endif
-
 # ifdef __cpp_lib_move_only_function
 #   error "__cpp_lib_move_only_function should not be defined before c++2b"
 # endif
@@ -4401,13 +4385,6 @@
 #   endif
 # endif
 
-# ifndef __cpp_lib_monadic_optional
-#   error "__cpp_lib_monadic_optional should be defined in c++2b"
-# endif
-# if __cpp_lib_monadic_optional != 202110L
-#   error "__cpp_lib_monadic_optional should have the value 202110L in c++2b"
-# endif
-
 # if !defined(_LIBCPP_VERSION)
 #   ifndef __cpp_lib_move_only_function
 #     error "__cpp_lib_move_only_function should be defined in c++2b"
@@ -4452,8 +4429,8 @@
 # ifndef __cpp_lib_optional
 #   error "__cpp_lib_optional should be defined in c++2b"
 # endif
-# if __cpp_lib_optional != 201606L
-#   error "__cpp_lib_optional should have the value 201606L in c++2b"
+# if __cpp_lib_optional != 202110L
+#   error "__cpp_lib_optional should have the value 202110L in c++2b"
 # endif
 
 # if !defined(_LIBCPP_VERSION)

diff  --git a/libcxx/utils/generate_feature_test_macro_components.py b/libcxx/utils/generate_feature_test_macro_components.py
index b8e82806c9f2e..60de8170616b3 100755
--- a/libcxx/utils/generate_feature_test_macro_components.py
+++ b/libcxx/utils/generate_feature_test_macro_components.py
@@ -470,10 +470,6 @@ def add_version_header(tc):
     "values": { "c++17": 201603 },
     "headers": ["memory_resource"],
     "unimplemented": True,
-  }, {
-    "name": "__cpp_lib_monadic_optional",
-    "values": { "c++2b": 202110 },
-    "headers": ["optional"],
   }, {
     "name": "__cpp_lib_move_only_function",
     "values": { "c++2b": 202110 },
@@ -497,7 +493,7 @@ def add_version_header(tc):
     "headers": ["iterator"],
   }, {
     "name": "__cpp_lib_optional",
-    "values": { "c++17": 201606 },
+    "values": { "c++17": 201606, "c++2b": 202110 },
     "headers": ["optional"],
   }, {
     "name": "__cpp_lib_out_ptr",


        


More information about the libcxx-commits mailing list