Revert "[libc] Use best-fit binary trie to make malloc logarithmic" (#117065)
[llvm-project.git] / libcxx / test / std / language.support / support.exception / propagation / make_exception_ptr.pass.cpp
blob8290b874db6479eb9412f021c756e7d782736d59
1 //===----------------------------------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
9 // UNSUPPORTED: no-exceptions
10 // <exception>
12 // template<class E> exception_ptr make_exception_ptr(E e);
14 #include <exception>
15 #include <cassert>
17 #include "test_macros.h"
19 struct A
21 static int constructed;
22 int data_;
24 A(int data = 0) : data_(data) {++constructed;}
25 ~A() {--constructed;}
26 A(const A& a) : data_(a.data_) {++constructed;}
29 int A::constructed = 0;
31 int main(int, char**)
34 std::exception_ptr p = std::make_exception_ptr(A(5));
35 try
37 std::rethrow_exception(p);
38 assert(false);
40 catch (const A& a)
42 #ifndef TEST_ABI_MICROSOFT
43 assert(A::constructed == 1);
44 #else
45 // On Windows exception_ptr copies the exception
46 assert(A::constructed == 2);
47 #endif
48 assert(p != nullptr);
49 p = nullptr;
50 assert(p == nullptr);
51 assert(a.data_ == 5);
52 assert(A::constructed == 1);
54 assert(A::constructed == 0);
56 assert(A::constructed == 0);
58 return 0;