OSDN Git Service

PR c++/51143 - Alias template allows class definition
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / g++.dg / cpp0x / implicit3.C
1 // Basic runtime test for implicit move constructor
2 // { dg-do run }
3 // { dg-options -std=c++0x }
4
5 int m;
6
7 struct A
8 {
9   A() = default;
10   A(A&&) { ++m; }
11   A& operator=(A&&) { ++m; return *this; }
12 };
13
14 struct B
15 {
16   B() = default;
17   B(const B&);
18   B(B&&) { ++m; }
19   B& operator=(const B&);
20   B& operator=(B&&) { ++m; return *this; }
21 };
22
23 struct C
24 {
25   C() = default;
26   C(C&);
27   C(C&&) { ++m; }
28   C& operator=(C&);
29   C& operator=(C&&) { ++m; return *this; }
30 };
31
32 struct D: public A, public B
33 {
34   C c;
35   int i;
36 };
37
38 struct E: public A, public B
39 {
40   C c;
41   int i;
42   E() = default;
43   E(E&&) = default;
44   E& operator=(E&&) = default;
45 };
46
47 int main()
48 {
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;
56 }