diff --git a/libcxx/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/dtor.pass.cpp b/libcxx/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/dtor.pass.cpp --- a/libcxx/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/dtor.pass.cpp +++ b/libcxx/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/dtor.pass.cpp @@ -25,18 +25,35 @@ #include "test_macros.h" +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(count_) ++*count_; } +}; +static_assert(!std::is_trivially_destructible::value, ""); + +static_assert(std::is_trivially_destructible>::value, ""); +static_assert(std::is_trivially_destructible>::value, ""); +static_assert(std::is_trivially_destructible>::value, ""); +static_assert(!std::is_trivially_destructible>::value, ""); +static_assert(!std::is_trivially_destructible>::value, ""); + +TEST_CONSTEXPR_CXX20 bool test() { + int count = 0; + { + std::tuple tuple{TrackDtor(&count)}; + assert(count == 0); + } + assert(count == 1); + + return true; +} + int main(int, char**) { - static_assert(std::is_trivially_destructible< - std::tuple<> >::value, ""); - static_assert(std::is_trivially_destructible< - std::tuple >::value, ""); - static_assert(std::is_trivially_destructible< - std::tuple >::value, ""); - static_assert(!std::is_trivially_destructible< - std::tuple >::value, ""); - static_assert(!std::is_trivially_destructible< - std::tuple >::value, ""); + static_assert(test()); + test(); return 0; }