Merged trunk at revision 161680 into branch.
[official-gcc.git] / gcc / testsuite / g++.dg / cpp0x / implicit3.C
bloba43eca708c0395614d52a8b223ff5777dfb52fbf
1 // Basic runtime test for implicit move constructor
2 // { dg-do run }
3 // { dg-options -std=c++0x }
5 int m;
7 struct A
9   A() = default;
10   A(A&&) { ++m; }
11   A& operator=(A&&) { ++m; return *this; }
14 struct B
16   B() = default;
17   B(const B&);
18   B(B&&) { ++m; }
19   B& operator=(const B&);
20   B& operator=(B&&) { ++m; return *this; }
23 struct C
25   C() = default;
26   C(C&);
27   C(C&&) { ++m; }
28   C& operator=(C&);
29   C& operator=(C&&) { ++m; return *this; }
32 struct D: public A, public B
34   C c;
35   int i;
38 struct E: public A, public B
40   C c;
41   int i;
42   E() = default;
43   E(E&&) = default;
44   E& operator=(E&&) = default;
47 int main()
49   D d1;
50   D d2 (static_cast<D&&>(d1));
51   d1 = static_cast<D&&>(d2);
52   E e1;
53   E e2 (static_cast<E&&>(e1));
54   e1 = static_cast<E&&>(e2);
55   return m != 12;