blob: cbe303c570d6ccc0c47167ffe6d7b7743b54df21 [file] [log] [blame]
Howard Hinnanted2c2912010-05-27 17:06:52 +00001//===----------------------------------------------------------------------===//
2//
3// The LLVM Compiler Infrastructure
4//
Howard Hinnantb64f8b02010-11-16 22:09:02 +00005// This file is dual licensed under the MIT and the University of Illinois Open
6// Source Licenses. See LICENSE.TXT for details.
Howard Hinnanted2c2912010-05-27 17:06:52 +00007//
8//===----------------------------------------------------------------------===//
9
Howard Hinnanted2c2912010-05-27 17:06:52 +000010// <exception>
11
12// class nested_exception;
13
14// nested_exception& operator=(const nested_exception&) throw() = default;
15
16#include <exception>
17#include <cassert>
18
19class A
20{
21 int data_;
22public:
23 explicit A(int data) : data_(data) {}
24
25 friend bool operator==(const A& x, const A& y) {return x.data_ == y.data_;}
26};
27
28int main()
29{
30 {
31 std::nested_exception e0;
32 std::nested_exception e;
33 e = e0;
34 assert(e.nested_ptr() == nullptr);
35 }
36 {
37 try
38 {
39 throw A(2);
40 assert(false);
41 }
42 catch (const A&)
43 {
44 std::nested_exception e0;
45 std::nested_exception e;
46 e = e0;
47 assert(e.nested_ptr() != nullptr);
48 try
49 {
50 rethrow_exception(e.nested_ptr());
51 assert(false);
52 }
53 catch (const A& a)
54 {
55 assert(a == A(2));
56 }
57 }
58 }
59}