[libcxx-commits] [PATCH] D115730: [libc++] Add a helper class to write code with the strong exception guarantee

Mark de Wever via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Wed Dec 15 09:23:47 PST 2021


Mordante added inline comments.


================
Comment at: libcxx/include/__utility/transaction.h:52
+struct __transaction {
+    __transaction() = delete;
+
----------------
Why not omit this?


================
Comment at: libcxx/include/__utility/transaction.h:55
+    _LIBCPP_HIDE_FROM_ABI
+    _LIBCPP_CONSTEXPR explicit __transaction(_Rollback __rollback)
+        : __rollback_(_VSTD::move(__rollback))
----------------
I see a lot of different `constexpr` macros in this class
`_LIBCPP_CONSTEXPR`, `_LIBCPP_CONSTEXPR_AFTER_CXX11` and `_LIBCPP_CONSTEXPR_AFTER_CXX17`. Looking at this I expect the class not be usable as constexpr before C++20, due to the `constexpr` macro for the destructor.


================
Comment at: libcxx/include/__utility/transaction.h:62
+    _LIBCPP_CONSTEXPR_AFTER_CXX11 __transaction(__transaction&& __other)
+        _NOEXCEPT_(is_nothrow_move_constructible<_Rollback>::value)
+        : __rollback_(_VSTD::move(__other.__rollback_))
----------------
The tests require C++11 or later.


================
Comment at: libcxx/test/libcxx/utilities/transaction.pass.cpp:155
+    test_exceptions();
+#if TEST_STD_VER > 17
+    static_assert(test(), "");
----------------
Please make sure this version matches the version in which the class is intended to be `constexpr`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115730



More information about the libcxx-commits mailing list