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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [g++.dg/] [cpp0x/] [not_special.C] - Blame information for rev 707

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

Line No. Rev Author Line
1 693 jeremybenn
// I, Howard Hinnant, hereby place this code in the public domain.
2
 
3
// Test that move constructor and move assignement are special.
4
//   That is, their presence should cause compiler declared
5
//   copy ctor or assignment to be deleted.
6
 
7
// { dg-options "-std=c++0x" }
8
 
9
#include 
10
 
11
template  struct sa;
12
template <> struct sa {};
13
 
14
struct one   {char x[1];};
15
struct two   {char x[2];};
16
 
17
int copy = 0;
18
int assign = 0;
19
 
20
struct base
21
{
22
    base() {}
23
    base(const base&) {++copy;}
24
    base& operator=(const base&) {++assign; return *this;}
25
};
26
 
27
struct derived                  // { dg-message "declares a move" }
28
    : base
29
{
30
    derived() {}
31
    derived(derived&&) {}
32
    derived& operator=(derived&&) {return *this;}
33
};
34
 
35
int test1()
36
{
37
    derived d;
38
    derived d2(static_cast(d));  // should not call base::(const base&)
39
    assert(copy == 0);
40
    derived d3(d);              // { dg-error "deleted" }
41
    assert(copy == 1);
42
    d2 = static_cast(d);         // should not call base::operator=
43
    assert(assign == 0);
44
    d3 = d;                     // { dg-error "deleted" }
45
    assert(assign == 1);
46
    return 0;
47
}
48
 
49
int main()
50
{
51
    return test1();
52
}

powered by: WebSVN 2.1.0

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