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