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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [libstdc++-v3/] [testsuite/] [20_util/] [move_if_noexcept/] [1.cc] - Blame information for rev 742

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 742 jeremybenn
// { dg-options "-std=gnu++0x" }
2
 
3
// 2011-04-27  Paolo Carlini  <paolo.carlini@oracle.com>
4
//
5
// Copyright (C) 2011 Free Software Foundation, Inc.
6
//
7
// This file is part of the GNU ISO C++ Library.  This library is free
8
// software; you can redistribute it and/or modify it under the
9
// terms of the GNU General Public License as published by the
10
// Free Software Foundation; either version 3, or (at your option)
11
// any later version.
12
//
13
// This library is distributed in the hope that it will be useful,
14
// but WITHOUT ANY WARRANTY; without even the implied warranty of
15
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
// GNU General Public License for more details.
17
//
18
// You should have received a copy of the GNU General Public License along
19
// with this library; see the file COPYING3.  If not see
20
// <http://www.gnu.org/licenses/>.
21
 
22
#include <utility>
23
#include <testsuite_hooks.h>
24
 
25
struct noexcept_move_copy
26
{
27
  noexcept_move_copy()
28
  : status(true)
29
  { };
30
 
31
  noexcept_move_copy(noexcept_move_copy&& r) noexcept
32
  { r.status = false; };
33
 
34
  noexcept_move_copy(const noexcept_move_copy&) = default;
35
 
36
  operator bool() { return status; }
37
 
38
private:
39
  bool status;
40
};
41
 
42
struct noexcept_move_no_copy
43
{
44
  noexcept_move_no_copy()
45
  : status(true)
46
  { };
47
 
48
  noexcept_move_no_copy(noexcept_move_no_copy&& r) noexcept
49
  { r.status = false; };
50
 
51
  noexcept_move_no_copy(const noexcept_move_no_copy&) = delete;
52
 
53
  operator bool() { return status; }
54
 
55
private:
56
  bool status;
57
};
58
 
59
struct except_move_copy
60
{
61
  except_move_copy()
62
  : status(true)
63
  { };
64
 
65
  except_move_copy(except_move_copy&& r) noexcept(false)
66
  { r.status = false; };
67
 
68
  except_move_copy(const except_move_copy&) = default;
69
 
70
  operator bool() { return status; }
71
 
72
private:
73
  bool status;
74
};
75
 
76
struct except_move_no_copy
77
{
78
  except_move_no_copy()
79
  : status(true)
80
  { };
81
 
82
  except_move_no_copy(except_move_no_copy&& r) noexcept(false)
83
  { r.status = false; };
84
 
85
  except_move_no_copy(const except_move_no_copy&) = delete;
86
 
87
  operator bool() { return status; }
88
 
89
private:
90
  bool status;
91
};
92
 
93
void
94
test01()
95
{
96
  bool test __attribute__((unused)) = true;
97
 
98
  noexcept_move_copy nemc1;
99
  auto nemc2 __attribute__((unused)) = std::move_if_noexcept(nemc1);
100
  VERIFY( nemc1 == false );
101
 
102
  noexcept_move_no_copy nemnc1;
103
  auto nemnc2 __attribute__((unused)) = std::move_if_noexcept(nemnc1);
104
  VERIFY( nemnc1 == false );
105
 
106
  except_move_copy emc1;
107
  auto emc2 __attribute__((unused)) = std::move_if_noexcept(emc1);
108
  VERIFY( emc1 == true );
109
 
110
  except_move_no_copy emnc1;
111
  auto emnc2 __attribute__((unused)) = std::move_if_noexcept(emnc1);
112
  VERIFY( emnc1 == false );
113
}
114
 
115
int main()
116
{
117
  test01();
118
  return 0;
119
}

powered by: WebSVN 2.1.0

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