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 // unique_ptr(nullptr_t);
15 
16 #include <memory>
17 #include <cassert>
18 
19 // default unique_ptr ctor should only require default Deleter ctor
20 class Deleter
21 {
22     int state_;
23 
24     Deleter(Deleter&);
25     Deleter& operator=(Deleter&);
26 
27 public:
Deleter()28     Deleter() : state_(5) {}
29 
state() const30     int state() const {return state_;}
31 
operator ()(void *)32     void operator()(void*) {}
33 };
34 
main()35 int main()
36 {
37     {
38     std::unique_ptr<int[]> p(nullptr);
39     assert(p.get() == 0);
40     }
41     {
42     std::unique_ptr<int[], Deleter> p(nullptr);
43     assert(p.get() == 0);
44     assert(p.get_deleter().state() == 5);
45     }
46 }
47