OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.5.1/] [gcc/] [testsuite/] [g++.dg/] [cpp0x/] [elision.C] - Blame information for rev 307

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 301 jeremybenn
// I, Howard Hinnant, hereby place this code in the public domain.
2
 
3
// Test: Implicit cast to rvalue when eliding copy
4
 
5
// { dg-do compile }
6
// { dg-options "-std=c++0x" }
7
 
8
template  struct sa;
9
template <> struct sa {};
10
 
11
struct one   {char x[1];};
12
struct two   {char x[2];};
13
 
14
class move_only
15
{
16
    move_only(const move_only&);
17
    move_only& operator=(const move_only&);
18
public:
19
    move_only() {}
20
    move_only(move_only&&) {}
21
    move_only& operator=(move_only&&) {return *this;}
22
};
23
 
24
move_only
25
test1()
26
{
27
    return move_only();
28
}
29
 
30
move_only
31
test2()
32
{
33
    move_only x;
34
    return x;
35
}
36
 
37
move_only
38
test3(bool b)
39
{
40
    move_only x1;
41
    if (b)
42
    {
43
        move_only x2;
44
        return x2;
45
    }
46
    return x1;
47
}
48
 
49
void
50
test4(bool b)
51
{
52
    if (!b)
53
        throw move_only();
54
}
55
 
56
void
57
test5(bool b)
58
{
59
    move_only x;
60
    if (!b)
61
        throw x;
62
}
63
 
64
extern bool b;
65
 
66
int main()
67
{
68
    move_only t1 = test1();
69
    move_only t2 = test2();
70
    move_only t3 = test3(b);
71
    test4(b);
72
    test5(b);
73
    return 0;
74
}
75
 
76
bool b = true;

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.