• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //===----------------------------------------------------------------------===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
10 // <memory>
11 
12 // unique_ptr
13 
14 // Test unique_ptr(pointer, deleter) ctor
15 
16 // unique_ptr(pointer, deleter()) only requires MoveConstructible deleter
17 
18 #include <memory>
19 #include <cassert>
20 
21 #include "../../deleter.h"
22 
23 struct A
24 {
25     static int count;
AA26     A() {++count;}
AA27     A(const A&) {++count;}
~AA28     ~A() {--count;}
29 };
30 
31 int A::count = 0;
32 
main()33 int main()
34 {
35     {
36     A* p = new A[3];
37     assert(A::count == 3);
38     std::unique_ptr<A[], Deleter<A[]> > s(p, Deleter<A[]>());
39     assert(s.get() == p);
40     assert(s.get_deleter().state() == 0);
41     }
42     assert(A::count == 0);
43 }
44