* decl.c (make_typename_type): s/parameters/arguments/.
[official-gcc.git] / gcc / testsuite / g++.dg / cpp0x / elision.C
blob4cc5653e24a416c0509776ec42ea5270ca9d97f8
1 // I, Howard Hinnant, hereby place this code in the public domain.
3 // Test: Implicit cast to rvalue when eliding copy
5 // { dg-do compile { target c++11 } }
7 template <bool> struct sa;
8 template <> struct sa<true> {};
10 struct one   {char x[1];};
11 struct two   {char x[2];};
13 class move_only
15     move_only(const move_only&);
16     move_only& operator=(const move_only&);
17 public:
18     move_only() {}
19     move_only(move_only&&) {}
20     move_only& operator=(move_only&&) {return *this;}
23 move_only
24 test1()
26     return move_only();
29 move_only
30 test2()
32     move_only x;
33     return x;
36 move_only
37 test3(bool b)
39     move_only x1;
40     if (b)
41     {
42         move_only x2;
43         return x2;
44     }
45     return x1;
48 void
49 test4(bool b)
51     if (!b)
52         throw move_only();
55 void
56 test5(bool b)
58     move_only x;
59     if (!b)
60         throw x;
63 extern bool b;
65 int main()
67     move_only t1 = test1();
68     move_only t2 = test2();
69     move_only t3 = test3(b);
70     test4(b);
71     test5(b);
72     return 0;
75 bool b = true;