1 //===----------------------------------------------------------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
12 // class nested_exception;
14 // template<class T> void throw_with_nested [[noreturn]] (T&& t);
24 explicit A(int data) : data_(data) {}
26 friend bool operator==(const A& x, const A& y) {return x.data_ == y.data_;}
30 : public std::nested_exception
34 explicit B(int data) : data_(data) {}
36 friend bool operator==(const B& x, const B& y) {return x.data_ == y.data_;}
39 #if __cplusplus > 201103L
40 struct Final final {};
49 std::throw_with_nested(a);
61 std::throw_with_nested(a);
64 catch (const std::nested_exception& e)
66 assert(e.nested_ptr() == nullptr);
73 std::throw_with_nested(b);
85 std::throw_with_nested(b);
88 catch (const std::nested_exception& e)
90 assert(e.nested_ptr() == nullptr);
91 const B& b = dynamic_cast<const B&>(e);
99 std::throw_with_nested(i);
107 #if __cplusplus > 201103L
111 std::throw_with_nested(Final());
114 catch (const Final &f)