]>
Commit | Line | Data |
---|---|---|
52066eae | 1 | // { dg-do run { target c++11 } } |
b4e77f9b | 2 | |
a945c346 | 3 | // Copyright (C) 2010-2024 Free Software Foundation, Inc. |
b4e77f9b JW |
4 | // |
5 | // This file is part of the GNU ISO C++ Library. This library is free | |
6 | // software; you can redistribute it and/or modify it under the | |
7 | // terms of the GNU General Public License as published by the | |
8 | // Free Software Foundation; either version 3, or (at your option) | |
9 | // any later version. | |
10 | ||
11 | // This library is distributed in the hope that it will be useful, | |
12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | // GNU General Public License for more details. | |
15 | ||
16 | // You should have received a copy of the GNU General Public License along | |
17 | // with this library; see the file COPYING3. If not see | |
18 | // <http://www.gnu.org/licenses/>. | |
19 | ||
20 | #include <exception> | |
21 | #include <testsuite_hooks.h> | |
22 | ||
23 | // test NullablePointer requirements | |
24 | void test01() | |
25 | { | |
26 | std::exception_ptr p1; // DefaultConstructible | |
27 | std::exception_ptr p2(p1); // CopyConstructible | |
28 | p1 = p2; // CopyAssignable | |
29 | VERIFY( p1 == p2 ); // EqualityComparable | |
30 | VERIFY( !bool(p1) ); // contextually convertible to bool | |
31 | swap(p1, p2); // Swappable | |
32 | ||
33 | // Table 39 expressions | |
34 | std::exception_ptr p3 = nullptr; | |
35 | std::exception_ptr p4(nullptr); | |
36 | VERIFY( std::exception_ptr() == nullptr ); | |
37 | p4 = nullptr; | |
38 | VERIFY( p4 == nullptr ); | |
39 | VERIFY( nullptr == p4 ); | |
40 | VERIFY( (p4 != nullptr) == !(p4 == nullptr) ); | |
41 | VERIFY( (nullptr != p4) == !(p4 == nullptr) ); | |
42 | ||
43 | std::exception_ptr p5{}; // value initialized ... | |
44 | VERIFY( p5 == nullptr ); // ... is equivalent to null | |
45 | } | |
46 | ||
47 | // additional exception_ptr requirements | |
48 | void test02() | |
49 | { | |
50 | std::exception_ptr p1; | |
51 | VERIFY( p1 == nullptr ); | |
52 | } | |
53 | ||
54 | int main() | |
55 | { | |
56 | test01(); | |
57 | test02(); | |
58 | return 0; | |
59 | } |