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 // template <class T1, class D1, class T2, class D2>
15 // bool
16 // operator< (const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y);
17
18 // template <class T1, class D1, class T2, class D2>
19 // bool
20 // operator> (const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y);
21
22 // template <class T1, class D1, class T2, class D2>
23 // bool
24 // operator<=(const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y);
25
26 // template <class T1, class D1, class T2, class D2>
27 // bool
28 // operator>=(const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y);
29
30 #include <memory>
31 #include <cassert>
32
33 #include "deleter_types.h"
34
35 struct A
36 {
37 static int count;
AA38 A() {++count;}
AA39 A(const A&) {++count;}
~AA40 virtual ~A() {--count;}
41 };
42
43 int A::count = 0;
44
45 struct B
46 : public A
47 {
48 static int count;
BB49 B() {++count;}
BB50 B(const B&) {++count;}
~BB51 virtual ~B() {--count;}
52 };
53
54 int B::count = 0;
55
main()56 int main()
57 {
58 {
59 const std::unique_ptr<A, Deleter<A> > p1(new A);
60 const std::unique_ptr<A, Deleter<A> > p2(new A);
61 assert((p1 < p2) == !(p1 > p2));
62 assert((p1 < p2) == (p1 <= p2));
63 assert((p1 < p2) == !(p1 >= p2));
64 }
65 {
66 const std::unique_ptr<A, Deleter<A> > p1(new A);
67 const std::unique_ptr<B, Deleter<B> > p2(new B);
68 assert((p1 < p2) == !(p1 > p2));
69 assert((p1 < p2) == (p1 <= p2));
70 assert((p1 < p2) == !(p1 >= p2));
71 }
72 {
73 const std::unique_ptr<A[], Deleter<A[]> > p1(new A[3]);
74 const std::unique_ptr<A[], Deleter<A[]> > p2(new A[3]);
75 assert((p1 < p2) == !(p1 > p2));
76 assert((p1 < p2) == (p1 <= p2));
77 assert((p1 < p2) == !(p1 >= p2));
78 }
79 {
80 const std::unique_ptr<A[], Deleter<A[]> > p1(new A[3]);
81 const std::unique_ptr<B[], Deleter<B[]> > p2(new B[3]);
82 assert((p1 < p2) == !(p1 > p2));
83 assert((p1 < p2) == (p1 <= p2));
84 assert((p1 < p2) == !(p1 >= p2));
85 }
86 {
87 const std::unique_ptr<A, Deleter<A> > p1;
88 const std::unique_ptr<A, Deleter<A> > p2;
89 assert((p1 < p2) == (p1 > p2));
90 assert((p1 < p2) == !(p1 <= p2));
91 assert((p1 < p2) == !(p1 >= p2));
92 }
93 {
94 const std::unique_ptr<A, Deleter<A> > p1;
95 const std::unique_ptr<B, Deleter<B> > p2;
96 assert((p1 < p2) == (p1 > p2));
97 assert((p1 < p2) == !(p1 <= p2));
98 assert((p1 < p2) == !(p1 >= p2));
99 }
100 }
101