Debian Codegraph @

gcc/testsuite/g++.dg/cpp0x/implicit3.C

raw
1 // Basic runtime test for implicit move constructor
2 // { dg-do run { target c++11 } }
3
4 int m;
5
6 struct A
7 {
8 A() = default;
9 A(A&&) { ++m; }
10 A& operator=(A&&) { ++m; return *this; }
11 };
12
13 struct B
14 {
15 B() = default;
16 B(const B&);
17 B(B&&) { ++m; }
18 B& operator=(const B&);
19 B& operator=(B&&) { ++m; return *this; }
20 };
21
22 struct C
23 {
24 C() = default;
25 C(C&);
26 C(C&&) { ++m; }
27 C& operator=(C&);
28 C& operator=(C&&) { ++m; return *this; }
29 };
30
31 struct D: public A, public B
32 {
33 C c;
34 int i;
35 };
36
37 struct E: public A, public B
38 {
39 C c;
40 int i;
41 E() = default;
42 E(E&&) = default;
43 E& operator=(E&&) = default;
44 };
45
46 int main()
47 {
48 D d1;
49 D d2 (static_cast<D&&>(d1));
50 d1 = static_cast<D&&>(d2);
51 E e1;
52 E e2 (static_cast<E&&>(e1));
53 e1 = static_cast<E&&>(e2);
54 return m != 12;
55 }