[libcxx-commits] [PATCH] D109298: [libc++][test] Add tuple trivial dtor test
Joe Loser via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Thu Jun 9 20:38:57 PDT 2022
jloser updated this revision to Diff 435784.
jloser retitled this revision from "[libc++][NFC] Make tuple dtor test compile test" to "[libc++][test] Add tuple trivial dtor test".
jloser edited the summary of this revision.
jloser added a comment.
Herald added a project: All.
Add runtime test
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D109298/new/
https://reviews.llvm.org/D109298
Files:
libcxx/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/dtor.pass.cpp
Index: libcxx/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/dtor.pass.cpp
===================================================================
--- libcxx/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/dtor.pass.cpp
+++ libcxx/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/dtor.pass.cpp
@@ -25,18 +25,33 @@
#include "test_macros.h"
+struct TrackDtor {
+ int* count_;
+ constexpr explicit TrackDtor(int* count) : count_(count) {}
+ ~TrackDtor() { ++*count_; }
+};
+
+bool test() {
+ int count = 0;
+ {
+ static_assert(!std::is_trivially_destructible<TrackDtor>::value);
+ std::tuple<TrackDtor> tuple{TrackDtor(&count)};
+ assert(count == 1);
+ }
+ assert(count == 2);
+
+ return true;
+}
+
int main(int, char**)
{
- static_assert(std::is_trivially_destructible<
- std::tuple<> >::value, "");
- static_assert(std::is_trivially_destructible<
- std::tuple<void*> >::value, "");
- static_assert(std::is_trivially_destructible<
- std::tuple<int, float> >::value, "");
- static_assert(!std::is_trivially_destructible<
- std::tuple<std::string> >::value, "");
- static_assert(!std::is_trivially_destructible<
- std::tuple<int, std::string> >::value, "");
+ static_assert(std::is_trivially_destructible<std::tuple<>>::value, "");
+ static_assert(std::is_trivially_destructible<std::tuple<void*>>::value, "");
+ static_assert(std::is_trivially_destructible<std::tuple<int, float>>::value, "");
+ static_assert(!std::is_trivially_destructible<std::tuple<std::string>>::value, "");
+ static_assert(!std::is_trivially_destructible<std::tuple<int, std::string>>::value, "");
+
+ test();
return 0;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D109298.435784.patch
Type: text/x-patch
Size: 1657 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20220610/27ed9339/attachment.bin>
More information about the libcxx-commits
mailing list