[libcxx-commits] [libcxx] [libc++] P2255R2: Set `__cpp_lib_reference_from_temporary` (PR #207920)

Yihan Wang via libcxx-commits libcxx-commits at lists.llvm.org
Tue Jul 7 01:04:34 PDT 2026


https://github.com/yronglin updated https://github.com/llvm/llvm-project/pull/207920

>From cdaede498c471d2e17572dd9ab7ae90d3ddb161a Mon Sep 17 00:00:00 2001
From: yronglin <yronglin777 at gmail.com>
Date: Tue, 7 Jul 2026 00:45:47 -0700
Subject: [PATCH 1/2] [libc++] P2255R2: Set __cpp_lib_reference_from_temporary

Signed-off-by: yronglin <yronglin777 at gmail.com>
---
 libcxx/docs/FeatureTestMacroTable.rst         |  2 +-
 libcxx/include/version                        |  2 +-
 .../type_traits.version.compile.pass.cpp      | 32 ++++++-------------
 .../version.version.compile.pass.cpp          | 32 ++++++-------------
 .../generate_feature_test_macro_components.py |  3 +-
 5 files changed, 23 insertions(+), 48 deletions(-)

diff --git a/libcxx/docs/FeatureTestMacroTable.rst b/libcxx/docs/FeatureTestMacroTable.rst
index 6bf2f35fb4212..2d8a9b513ad5c 100644
--- a/libcxx/docs/FeatureTestMacroTable.rst
+++ b/libcxx/docs/FeatureTestMacroTable.rst
@@ -398,7 +398,7 @@ Status
     ---------------------------------------------------------- -----------------
     ``__cpp_lib_ranges_zip``                                   ``202110L``
     ---------------------------------------------------------- -----------------
-    ``__cpp_lib_reference_from_temporary``                     *unimplemented*
+    ``__cpp_lib_reference_from_temporary``                     ``202202L``
     ---------------------------------------------------------- -----------------
     ``__cpp_lib_shift``                                        ``202202L``
     ---------------------------------------------------------- -----------------
diff --git a/libcxx/include/version b/libcxx/include/version
index 4a6b01093641d..cffadf4655ce2 100644
--- a/libcxx/include/version
+++ b/libcxx/include/version
@@ -542,7 +542,7 @@ __cpp_lib_void_t                                        201411L <type_traits>
 # define __cpp_lib_ranges_stride                        202207L
 # define __cpp_lib_ranges_to_container                  202202L
 # define __cpp_lib_ranges_zip                           202110L
-// # define __cpp_lib_reference_from_temporary             202202L
+# define __cpp_lib_reference_from_temporary             202202L
 # undef  __cpp_lib_shift
 # define __cpp_lib_shift                                202202L
 // # define __cpp_lib_spanstream                           202106L
diff --git a/libcxx/test/std/language.support/support.limits/support.limits.general/type_traits.version.compile.pass.cpp b/libcxx/test/std/language.support/support.limits/support.limits.general/type_traits.version.compile.pass.cpp
index cb5c008f16bb3..e69c4b5c97ea6 100644
--- a/libcxx/test/std/language.support/support.limits/support.limits.general/type_traits.version.compile.pass.cpp
+++ b/libcxx/test/std/language.support/support.limits/support.limits.general/type_traits.version.compile.pass.cpp
@@ -718,17 +718,11 @@
 #    error "__cpp_lib_logical_traits should have the value 201510L in c++23"
 #  endif
 
-#  if !defined(_LIBCPP_VERSION)
-#    ifndef __cpp_lib_reference_from_temporary
-#      error "__cpp_lib_reference_from_temporary should be defined in c++23"
-#    endif
-#    if __cpp_lib_reference_from_temporary != 202202L
-#      error "__cpp_lib_reference_from_temporary should have the value 202202L in c++23"
-#    endif
-#  else
-#    ifdef __cpp_lib_reference_from_temporary
-#      error "__cpp_lib_reference_from_temporary should not be defined because it is unimplemented in libc++!"
-#    endif
+#  ifndef __cpp_lib_reference_from_temporary
+#    error "__cpp_lib_reference_from_temporary should be defined in c++23"
+#  endif
+#  if __cpp_lib_reference_from_temporary != 202202L
+#    error "__cpp_lib_reference_from_temporary should have the value 202202L in c++23"
 #  endif
 
 #  ifndef __cpp_lib_remove_cvref
@@ -938,17 +932,11 @@
 #    error "__cpp_lib_logical_traits should have the value 201510L in c++26"
 #  endif
 
-#  if !defined(_LIBCPP_VERSION)
-#    ifndef __cpp_lib_reference_from_temporary
-#      error "__cpp_lib_reference_from_temporary should be defined in c++26"
-#    endif
-#    if __cpp_lib_reference_from_temporary != 202202L
-#      error "__cpp_lib_reference_from_temporary should have the value 202202L in c++26"
-#    endif
-#  else
-#    ifdef __cpp_lib_reference_from_temporary
-#      error "__cpp_lib_reference_from_temporary should not be defined because it is unimplemented in libc++!"
-#    endif
+#  ifndef __cpp_lib_reference_from_temporary
+#    error "__cpp_lib_reference_from_temporary should be defined in c++26"
+#  endif
+#  if __cpp_lib_reference_from_temporary != 202202L
+#    error "__cpp_lib_reference_from_temporary should have the value 202202L in c++26"
 #  endif
 
 #  ifndef __cpp_lib_remove_cvref
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 f2d74cc99d864..4afa5cc09c57c 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
@@ -5907,17 +5907,11 @@
 #    error "__cpp_lib_rcu should not be defined before c++26"
 #  endif
 
-#  if !defined(_LIBCPP_VERSION)
-#    ifndef __cpp_lib_reference_from_temporary
-#      error "__cpp_lib_reference_from_temporary should be defined in c++23"
-#    endif
-#    if __cpp_lib_reference_from_temporary != 202202L
-#      error "__cpp_lib_reference_from_temporary should have the value 202202L in c++23"
-#    endif
-#  else
-#    ifdef __cpp_lib_reference_from_temporary
-#      error "__cpp_lib_reference_from_temporary should not be defined because it is unimplemented in libc++!"
-#    endif
+#  ifndef __cpp_lib_reference_from_temporary
+#    error "__cpp_lib_reference_from_temporary should be defined in c++23"
+#  endif
+#  if __cpp_lib_reference_from_temporary != 202202L
+#    error "__cpp_lib_reference_from_temporary should have the value 202202L in c++23"
 #  endif
 
 #  ifdef __cpp_lib_reference_wrapper
@@ -7876,17 +7870,11 @@
 #    endif
 #  endif
 
-#  if !defined(_LIBCPP_VERSION)
-#    ifndef __cpp_lib_reference_from_temporary
-#      error "__cpp_lib_reference_from_temporary should be defined in c++26"
-#    endif
-#    if __cpp_lib_reference_from_temporary != 202202L
-#      error "__cpp_lib_reference_from_temporary should have the value 202202L in c++26"
-#    endif
-#  else
-#    ifdef __cpp_lib_reference_from_temporary
-#      error "__cpp_lib_reference_from_temporary should not be defined because it is unimplemented in libc++!"
-#    endif
+#  ifndef __cpp_lib_reference_from_temporary
+#    error "__cpp_lib_reference_from_temporary should be defined in c++26"
+#  endif
+#  if __cpp_lib_reference_from_temporary != 202202L
+#    error "__cpp_lib_reference_from_temporary should have the value 202202L in c++26"
 #  endif
 
 #  ifndef __cpp_lib_reference_wrapper
diff --git a/libcxx/utils/generate_feature_test_macro_components.py b/libcxx/utils/generate_feature_test_macro_components.py
index f4e16078d5af0..9794f3d453703 100644
--- a/libcxx/utils/generate_feature_test_macro_components.py
+++ b/libcxx/utils/generate_feature_test_macro_components.py
@@ -1223,8 +1223,7 @@ def add_version_header(tc):
         {
             "name": "__cpp_lib_reference_from_temporary",
             "values": {"c++23": 202202},
-            "headers": ["type_traits"],
-            "unimplemented": True,
+            "headers": ["type_traits"]
         },
         {
             "name": "__cpp_lib_reference_wrapper",

>From 32e22fcd81abc2282f3cbe06ba2ccc5e4cce74d8 Mon Sep 17 00:00:00 2001
From: yronglin <yronglin777 at gmail.com>
Date: Tue, 7 Jul 2026 01:04:16 -0700
Subject: [PATCH 2/2] Format

Signed-off-by: yronglin <yronglin777 at gmail.com>
---
 libcxx/utils/generate_feature_test_macro_components.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libcxx/utils/generate_feature_test_macro_components.py b/libcxx/utils/generate_feature_test_macro_components.py
index 9794f3d453703..26cf78154205d 100644
--- a/libcxx/utils/generate_feature_test_macro_components.py
+++ b/libcxx/utils/generate_feature_test_macro_components.py
@@ -1223,7 +1223,7 @@ def add_version_header(tc):
         {
             "name": "__cpp_lib_reference_from_temporary",
             "values": {"c++23": 202202},
-            "headers": ["type_traits"]
+            "headers": ["type_traits"],
         },
         {
             "name": "__cpp_lib_reference_wrapper",



More information about the libcxx-commits mailing list