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