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
20 // test converting move ctor. Should only require a MoveConstructible deleter, or if
21 // deleter is a reference, not even that.
28 A(const A&) {++count;}
29 virtual ~A() {--count;}
39 B(const B&) {++count;}
40 virtual ~B() {--count;}
51 CDeleter& operator=(CDeleter&);
54 CDeleter() : state_(5) {}
56 int state() const {return state_;}
57 void set_state(int s) {state_ = s;}
59 void operator()(T* p) {delete p;}
66 std::unique_ptr<B, CDeleter<A>&> s(new B, d);
68 std::unique_ptr<A, CDeleter<A>&> s2(s);
69 assert(s2.get() == p);
71 assert(A::count == 1);
72 assert(B::count == 1);
74 assert(s2.get_deleter().state() == d.state());
75 assert(s.get_deleter().state() == d.state());
77 assert(A::count == 0);
78 assert(B::count == 0);