1 //===----------------------------------------------------------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
14 // Test unique_ptr converting move ctor
16 // test converting move ctor. Should only require a MoveConstructible deleter, or if
17 // deleter is a reference, not even that.
27 A(const A&) {++count;}
28 virtual ~A() {--count;}
38 B(const B&) {++count;}
39 virtual ~B() {--count;}
50 CDeleter& operator=(CDeleter&);
53 CDeleter() : state_(5) {}
55 int state() const {return state_;}
56 void set_state(int s) {state_ = s;}
58 void operator()(T* p) {delete p;}
65 std::unique_ptr<B[], CDeleter<A>&> s(new B, d);
67 std::unique_ptr<A[], CDeleter<A>&> s2 = std::move(s);
68 assert(s2.get() == p);
70 assert(A::count == 1);
71 assert(B::count == 1);
73 assert(s2.get_deleter().state() == d.state());
74 assert(s.get_deleter().state() == d.state());
76 assert(A::count == 0);
77 assert(B::count == 0);