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
//===----------------------------------------------------------------------===//
19
#include "../../deleter.h"
25
explicit A(int i) : state_(i) {++count;}
26
A(const A& a) : state_(a.state_) {++count;}
27
A& operator=(const A& a) {state_ = a.state_; return *this;}
30
friend bool operator==(const A& x, const A& y)
31
{return x.state_ == y.state_;}
40
std::unique_ptr<A, Deleter<A> > s1(p1, Deleter<A>(1));
42
std::unique_ptr<A, Deleter<A> > s2(p2, Deleter<A>(2));
43
assert(s1.get() == p1);
45
assert(s1.get_deleter().state() == 1);
46
assert(s2.get() == p2);
48
assert(s2.get_deleter().state() == 2);
50
assert(s1.get() == p2);
52
assert(s1.get_deleter().state() == 2);
53
assert(s2.get() == p1);
55
assert(s2.get_deleter().state() == 1);
56
assert(A::count == 2);
58
assert(A::count == 0);