[libcxx-commits] [libcxx] [libc++] Use `__reference_constructs_from_temporary` if eligible (PR #141916)
Nikolas Klauser via libcxx-commits
libcxx-commits at lists.llvm.org
Mon Jun 2 08:04:18 PDT 2025
================
@@ -30,6 +30,19 @@ _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool reference_constructs_from_tempo
#endif
+#if __has_builtin(__reference_constructs_from_temporary)
+template <class _Tp, class _Up>
+inline const bool __reference_constructs_from_temporary_v = __reference_constructs_from_temporary(_Tp, _Up);
+#elif __has_builtin(__reference_binds_to_temporary)
+// TODO: Remove this once all support compilers have __reference_constructs_from_temporary implemented.
+template <class _Tp, class _Up>
+inline const bool __reference_constructs_from_temporary_v = __reference_binds_to_temporary(_Tp, _Up);
+#else
+// TODO: Remove this once https://github.com/llvm/llvm-project/issues/111477 no longer affects supported compilers.
+template <class _Tp, class _Up>
+inline const bool __reference_constructs_from_temporary_v = false;
+#endif
----------------
philnik777 wrote:
I'm pretty sure we can just remove this and make the `__reference_binds_to_temporary` the `#else` case instead. AFAICT the builtin is recognized properly, even if `__has_builtin(__reference_binds_to_temporary)` is false. Also, let's add a `// TODO(LLVM 22)` that we can remove the branches entirely.
https://github.com/llvm/llvm-project/pull/141916
More information about the libcxx-commits
mailing list