[libcxx-commits] [libcxx] 99b7c2b - [libc++] Remove conditional usage of rvalue references in C++03

Louis Dionne via libcxx-commits libcxx-commits at lists.llvm.org
Fri Mar 10 11:44:03 PST 2023


Author: Louis Dionne
Date: 2023-03-10T14:43:18-05:00
New Revision: 99b7c2bad3e5898353223c4682dce8ce31a69f30

URL: https://github.com/llvm/llvm-project/commit/99b7c2bad3e5898353223c4682dce8ce31a69f30
DIFF: https://github.com/llvm/llvm-project/commit/99b7c2bad3e5898353223c4682dce8ce31a69f30.diff

LOG: [libc++] Remove conditional usage of rvalue references in C++03

This one is easy -- Clang supports rvalue references in C++03 mode, so
we should be able to remove that conditional.

As a fly-by fix, turn a few static_casts to std::forward.

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

Added: 
    

Modified: 
    libcxx/include/exception

Removed: 
    


################################################################################
diff  --git a/libcxx/include/exception b/libcxx/include/exception
index 2b08f11fbf332..2b5cfd52ae186 100644
--- a/libcxx/include/exception
+++ b/libcxx/include/exception
@@ -87,6 +87,7 @@ template <class E> void rethrow_if_nested(const E& e);
 #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 @@ struct __throw_with_nested<_Tp, _Up, true> {
     _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 @@ throw_with_nested(_Tp&& __t)
         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


        


More information about the libcxx-commits mailing list