[libcxx-commits] [libcxx] [libc++][type_traits] Implements "A type trait to detect reference binding to temporary" (PR #128649)

A. Jiang via libcxx-commits libcxx-commits at lists.llvm.org
Wed Mar 5 23:18:10 PST 2025


================
@@ -1215,6 +1215,21 @@ typedef __char32_t char32_t;
 #    define _LIBCPP_HAS_EXPLICIT_THIS_PARAMETER 0
 #  endif
 
+// TODO(LLVM 22): Remove this macro once LLVM19 support ends.
+#  if __has_builtin(__reference_constructs_from_temporary) ||                                                          \
+      (defined(_LIBCPP_CLANG_VER) && (_LIBCPP_CLANG_VER >= 1900))
+#    define _LIBCPP_HAS_REFERENCE_CONSTRUCTS_FROM_TEMPORARY 1
+#  else
+#    define _LIBCPP_HAS_REFERENCE_CONSTRUCTS_FROM_TEMPORARY 0
+#  endif
+
+// TODO(LLVM 22): Remove this macro once LLVM19 support ends.
+#  if __has_builtin(__reference_converts_from_temporary) || (defined(_LIBCPP_CLANG_VER) && (_LIBCPP_CLANG_VER >= 1901))
----------------
frederick-vs-ja wrote:

Thanks for the information! I just remembered `__reference_converts_from_temporary` is implemented far earlier than the branching of LLVM 19.x, but according to your information, it seems that Android Clang 19.0/20.0 are more similar to the previous version of Clang (18/19) at branching.

https://github.com/llvm/llvm-project/pull/128649


More information about the libcxx-commits mailing list