1 // { dg-options "-std=gnu++0x" }
3 // 2011-04-27 Paolo Carlini <paolo.carlini@oracle.com>
5 // Copyright (C) 2011-2013 Free Software Foundation, Inc.
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)
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.
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/>.
23 #include <testsuite_hooks.h>
25 struct noexcept_move_copy
31 noexcept_move_copy(noexcept_move_copy
&& r
) noexcept
32 { r
.status
= false; };
34 noexcept_move_copy(const noexcept_move_copy
&) = default;
36 operator bool() { return status
; }
42 struct noexcept_move_no_copy
44 noexcept_move_no_copy()
48 noexcept_move_no_copy(noexcept_move_no_copy
&& r
) noexcept
49 { r
.status
= false; };
51 noexcept_move_no_copy(const noexcept_move_no_copy
&) = delete;
53 operator bool() { return status
; }
59 struct except_move_copy
65 except_move_copy(except_move_copy
&& r
) noexcept(false)
66 { r
.status
= false; };
68 except_move_copy(const except_move_copy
&) = default;
70 operator bool() { return status
; }
76 struct except_move_no_copy
82 except_move_no_copy(except_move_no_copy
&& r
) noexcept(false)
83 { r
.status
= false; };
85 except_move_no_copy(const except_move_no_copy
&) = delete;
87 operator bool() { return status
; }
96 bool test
__attribute__((unused
)) = true;
98 noexcept_move_copy nemc1
;
99 auto nemc2
__attribute__((unused
)) = std::move_if_noexcept(nemc1
);
100 VERIFY( nemc1
== false );
102 noexcept_move_no_copy nemnc1
;
103 auto nemnc2
__attribute__((unused
)) = std::move_if_noexcept(nemnc1
);
104 VERIFY( nemnc1
== false );
106 except_move_copy emc1
;
107 auto emc2
__attribute__((unused
)) = std::move_if_noexcept(emc1
);
108 VERIFY( emc1
== true );
110 except_move_no_copy emnc1
;
111 auto emnc2
__attribute__((unused
)) = std::move_if_noexcept(emnc1
);
112 VERIFY( emnc1
== false );