[libcxx-commits] [libcxx] 201b2b5 - [libc++] Reorganize exception_guard

Louis Dionne via libcxx-commits libcxx-commits at lists.llvm.org
Mon Feb 13 08:50:39 PST 2023


Author: Louis Dionne
Date: 2023-02-13T11:50:24-05:00
New Revision: 201b2b5674e1994e56756a013c7dd7ee7be81419

URL: https://github.com/llvm/llvm-project/commit/201b2b5674e1994e56756a013c7dd7ee7be81419
DIFF: https://github.com/llvm/llvm-project/commit/201b2b5674e1994e56756a013c7dd7ee7be81419.diff

LOG: [libc++] Reorganize exception_guard

We try to keep as little code as possible within #ifdef.

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

Added: 
    

Modified: 
    libcxx/include/__utility/exception_guard.h

Removed: 
    


################################################################################
diff  --git a/libcxx/include/__utility/exception_guard.h b/libcxx/include/__utility/exception_guard.h
index 46f9359a5c0e3..f7d1d4b309efe 100644
--- a/libcxx/include/__utility/exception_guard.h
+++ b/libcxx/include/__utility/exception_guard.h
@@ -58,7 +58,6 @@ _LIBCPP_BEGIN_NAMESPACE_STD
 //    }
 //
 
-#ifndef _LIBCPP_NO_EXCEPTIONS
 template <class _Rollback>
 struct __exception_guard_exceptions {
   __exception_guard_exceptions() = delete;
@@ -91,9 +90,6 @@ struct __exception_guard_exceptions {
 
 _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(__exception_guard_exceptions);
 
-template <class _Rollback>
-using __exception_guard = __exception_guard_exceptions<_Rollback>;
-#else  // _LIBCPP_NO_EXCEPTIONS
 template <class _Rollback>
 struct __exception_guard_noexceptions {
   __exception_guard_noexceptions() = delete;
@@ -125,9 +121,13 @@ struct __exception_guard_noexceptions {
 
 _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(__exception_guard_noexceptions);
 
+#ifdef _LIBCPP_NO_EXCEPTIONS
 template <class _Rollback>
 using __exception_guard = __exception_guard_noexceptions<_Rollback>;
-#endif // _LIBCPP_NO_EXCEPTIONS
+#else
+template <class _Rollback>
+using __exception_guard = __exception_guard_exceptions<_Rollback>;
+#endif
 
 template <class _Rollback>
 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR __exception_guard<_Rollback> __make_exception_guard(_Rollback __rollback) {


        


More information about the libcxx-commits mailing list