]>
git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/18_support/exception_ptr/requirements.cc
1 // { dg-do run { target c++11 } }
3 // Copyright (C) 2010-2024 Free Software Foundation, Inc.
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)
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.
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/>.
21 #include <testsuite_hooks.h>
23 // test NullablePointer requirements
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
33 // Table 39 expressions
34 std::exception_ptr p3
= nullptr;
35 std::exception_ptr
p4(nullptr);
36 VERIFY( std::exception_ptr() == nullptr );
38 VERIFY( p4
== nullptr );
39 VERIFY( nullptr == p4
);
40 VERIFY( (p4
!= nullptr) == !(p4
== nullptr) );
41 VERIFY( (nullptr != p4
) == !(p4
== nullptr) );
43 std::exception_ptr p5
{}; // value initialized ...
44 VERIFY( p5
== nullptr ); // ... is equivalent to null
47 // additional exception_ptr requirements
50 std::exception_ptr p1
;
51 VERIFY( p1
== nullptr );