[libcxx-commits] [PATCH] D143299: [libc++] Reorganize exception_guard

Louis Dionne via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Fri Feb 3 15:03:29 PST 2023


ldionne created this revision.
Herald added a project: All.
ldionne requested review of this revision.
Herald added a project: libc++.
Herald added a subscriber: libcxx-commits.
Herald added a reviewer: libc++.

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


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D143299

Files:
  libcxx/include/__utility/exception_guard.h


Index: libcxx/include/__utility/exception_guard.h
===================================================================
--- libcxx/include/__utility/exception_guard.h
+++ libcxx/include/__utility/exception_guard.h
@@ -58,7 +58,6 @@
 //    }
 //
 
-#ifndef _LIBCPP_NO_EXCEPTIONS
 template <class _Rollback>
 struct __exception_guard_exceptions {
   __exception_guard_exceptions() = delete;
@@ -91,9 +90,6 @@
 
 _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 @@
 
 _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) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D143299.494749.patch
Type: text/x-patch
Size: 1227 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20230203/26311454/attachment.bin>


More information about the libcxx-commits mailing list