[RISCV] Fix mgather -> riscv.masked.strided.load combine not extending indices (...
[llvm-project.git] / libcxx / test / std / utilities / variant / variant.variant / variant.dtor / dtor.pass.cpp
blob2e026038c97a3c99b6f60adeeb92a80c91d8bf0b
1 //===----------------------------------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
9 // UNSUPPORTED: c++03, c++11, c++14
11 // <variant>
13 // template <class ...Types> class variant;
15 // ~variant();
17 #include <cassert>
18 #include <type_traits>
19 #include <variant>
21 #include "test_macros.h"
23 struct NonTDtor {
24 static int count;
25 NonTDtor() = default;
26 ~NonTDtor() { ++count; }
28 int NonTDtor::count = 0;
29 static_assert(!std::is_trivially_destructible<NonTDtor>::value, "");
31 struct NonTDtor1 {
32 static int count;
33 NonTDtor1() = default;
34 ~NonTDtor1() { ++count; }
36 int NonTDtor1::count = 0;
37 static_assert(!std::is_trivially_destructible<NonTDtor1>::value, "");
39 struct TDtor {
40 TDtor(const TDtor &) {} // non-trivial copy
41 ~TDtor() = default;
43 static_assert(!std::is_trivially_copy_constructible<TDtor>::value, "");
44 static_assert(std::is_trivially_destructible<TDtor>::value, "");
46 int main(int, char**) {
48 using V = std::variant<int, long, TDtor>;
49 static_assert(std::is_trivially_destructible<V>::value, "");
52 using V = std::variant<NonTDtor, int, NonTDtor1>;
53 static_assert(!std::is_trivially_destructible<V>::value, "");
55 V v(std::in_place_index<0>);
56 assert(NonTDtor::count == 0);
57 assert(NonTDtor1::count == 0);
59 assert(NonTDtor::count == 1);
60 assert(NonTDtor1::count == 0);
61 NonTDtor::count = 0;
62 { V v(std::in_place_index<1>); }
63 assert(NonTDtor::count == 0);
64 assert(NonTDtor1::count == 0);
66 V v(std::in_place_index<2>);
67 assert(NonTDtor::count == 0);
68 assert(NonTDtor1::count == 0);
70 assert(NonTDtor::count == 0);
71 assert(NonTDtor1::count == 1);
74 return 0;