blob: ab2c73e0c5f1a4d99f1043a0e85ee2dcc5b20eba [file] [log] [blame]
Howard Hinnantc52f43e2010-08-22 00:59:46 +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 Hinnantc52f43e2010-08-22 00:59:46 +00007//
8//===----------------------------------------------------------------------===//
9
10// <memory>
11
12// template<class D, class A> shared_ptr(nullptr_t, D d, A a);
13
14#include <memory>
15#include <cassert>
16#include "../test_deleter.h"
Marshall Clow1b921882013-12-03 00:18:10 +000017#include "test_allocator.h"
Howard Hinnantc52f43e2010-08-22 00:59:46 +000018
19struct A
20{
21 static int count;
22
23 A() {++count;}
24 A(const A&) {++count;}
25 ~A() {--count;}
26};
27
28int A::count = 0;
29
30int main()
31{
32 try
33 {
34 test_allocator<A>::throw_after = 0;
35 std::shared_ptr<A> p(nullptr, test_deleter<A>(3), test_allocator<A>(5));
36 assert(false);
37 }
38 catch (std::bad_alloc&)
39 {
40 assert(A::count == 0);
41 assert(test_deleter<A>::count == 0);
42 assert(test_deleter<A>::dealloc_count == 1);
43 assert(test_allocator<A>::count == 0);
44 assert(test_allocator<A>::alloc_count == 0);
45 }
46}