[libcxx-commits] [PATCH] D145701: [libc++] Remove conditional usage of rvalue references in C++03

Louis Dionne via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Fri Mar 10 06:04:34 PST 2023


ldionne updated this revision to Diff 504119.
ldionne added a comment.

Address comments and rebase (should fix CI).


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D145701/new/

https://reviews.llvm.org/D145701

Files:
  libcxx/include/exception


Index: libcxx/include/exception
===================================================================
--- libcxx/include/exception
+++ libcxx/include/exception
@@ -87,6 +87,7 @@
 #include <__type_traits/is_copy_constructible.h>
 #include <__type_traits/is_final.h>
 #include <__type_traits/is_polymorphic.h>
+#include <__utility/forward.h>
 #include <cstddef>
 #include <cstdlib>
 #include <version>
@@ -313,20 +314,16 @@
     _LIBCPP_NORETURN static inline _LIBCPP_INLINE_VISIBILITY void
     __do_throw(_Tp&& __t)
     {
-        throw __nested<_Up>(static_cast<_Tp&&>(__t));
+        throw __nested<_Up>(std::forward<_Tp>(__t));
     }
 };
 
 template <class _Tp, class _Up>
 struct __throw_with_nested<_Tp, _Up, false> {
     _LIBCPP_NORETURN static inline _LIBCPP_INLINE_VISIBILITY void
-#ifndef _LIBCPP_CXX03_LANG
     __do_throw(_Tp&& __t)
-#else
-    __do_throw (_Tp& __t)
-#endif // _LIBCPP_CXX03_LANG
     {
-        throw static_cast<_Tp&&>(__t);
+        throw std::forward<_Tp>(__t);
     }
 };
 #endif
@@ -343,7 +340,7 @@
         is_class<_Up>::value &&
         !is_base_of<nested_exception, _Up>::value &&
         !__libcpp_is_final<_Up>::value>::
-            __do_throw(static_cast<_Tp&&>(__t));
+            __do_throw(std::forward<_Tp>(__t));
 #else
     ((void)__t);
     // FIXME: Make this abort


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D145701.504119.patch
Type: text/x-patch
Size: 1319 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20230310/1202260a/attachment.bin>


More information about the libcxx-commits mailing list