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

Subversion Repositories openrisc

[/] [openrisc/] [tags/] [gnu-src/] [gcc-4.5.1/] [gcc-4.5.1-or32-1.0rc1/] [gcc/] [testsuite/] [g++.dg/] [cpp0x/] [not_special.C] - Blame information for rev 338

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 that move constructor and move assignement are not special.
4
//   That is, their presence should not inhibit compiler generated
5
//   copy ctor or assignment.  Rather they should overload with the
6
//   compiler generated special members.
7
 
8
// { dg-do run }
9
// { dg-options "-std=c++0x" }
10
 
11
#include 
12
 
13
template  struct sa;
14
template <> struct sa {};
15
 
16
struct one   {char x[1];};
17
struct two   {char x[2];};
18
 
19
int copy = 0;
20
int assign = 0;
21
 
22
struct base
23
{
24
    base() {}
25
    base(const base&) {++copy;}
26
    base& operator=(const base&) {++assign; return *this;}
27
};
28
 
29
struct derived
30
    : base
31
{
32
    derived() {}
33
    derived(derived&&) {}
34
    derived& operator=(derived&&) {return *this;}
35
};
36
 
37
int test1()
38
{
39
    derived d;
40
    derived d2(static_cast(d));  // should not call base::(const base&)
41
    assert(copy == 0);
42
    derived d3(d);                          // should     call base::(const base&)
43
    assert(copy == 1);
44
    d2 = static_cast(d);         // should not call base::operator=
45
    assert(assign == 0);
46
    d3 = d;                                 // should     call base::operator=
47
    assert(assign == 1);
48
    return 0;
49
}
50
 
51
int main()
52
{
53
    return test1();
54
}

powered by: WebSVN 2.1.0

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