[libcxx-commits] [PATCH] D109298: [libc++][test] Add tuple trivial destructor test

Mark de Wever via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Sat Jun 11 11:19:58 PDT 2022


Mordante added inline comments.


================
Comment at: libcxx/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/dtor.pass.cpp:40
+    std::tuple<TrackDtor> tuple{TrackDtor(&count)};
+    assert(count == 1);
+  }
----------------
This differs from @ldionne's suggestion. I wonder whether we should make sure the destruction of the temporary shouldn't increase the counter. Something like:
```
struct TrackDtor {
   int* count_;
   constexpr explicit TrackDtor(int* count) : count_(count) {}
   constexpr TrackDtor(TrackDtor&& that) : count_(that.count_) { that.count_ = nullptr}
   TEST_CONSTEXPR_CXX20 ~TrackDtor() { if(coount_) ++*count_; }
};

```
WDYT?


================
Comment at: libcxx/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/dtor.pass.cpp:51
+static_assert(!std::is_trivially_destructible<std::tuple<std::string>>::value, "");
+static_assert(!std::is_trivially_destructible<std::tuple<int, std::string>>::value, "");
+
----------------
Maybe move this to the other `static_assert` at line 33.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109298



More information about the libcxx-commits mailing list