1 //===----------------------------------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8
9 // <memory>
10
11 // unique_ptr
12
13 // template <class T1, class D1, class T2, class D2>
14 // bool
15 // operator==(const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y);
16
17 // template <class T1, class D1, class T2, class D2>
18 // bool
19 // operator!=(const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y);
20
21 #include <memory>
22 #include <cassert>
23
24 #include "test_macros.h"
25 #include "deleter_types.h"
26
27 struct A
28 {
29 static int count;
AA30 A() {++count;}
AA31 A(const A&) {++count;}
~AA32 virtual ~A() {--count;}
33 };
34
35 int A::count = 0;
36
37 struct B
38 : public A
39 {
40 static int count;
BB41 B() {++count;}
BB42 B(const B& other) : A(other) {++count;}
~BB43 virtual ~B() {--count;}
44 };
45
46 int B::count = 0;
47
main(int,char **)48 int main(int, char**)
49 {
50 {
51 const std::unique_ptr<A, Deleter<A> > p1(new A);
52 const std::unique_ptr<A, Deleter<A> > p2(new A);
53 assert(!(p1 == p2));
54 assert(p1 != p2);
55 }
56 {
57 const std::unique_ptr<A, Deleter<A> > p1(new A);
58 const std::unique_ptr<B, Deleter<B> > p2(new B);
59 assert(!(p1 == p2));
60 assert(p1 != p2);
61 }
62 {
63 const std::unique_ptr<A[], Deleter<A[]> > p1(new A[3]);
64 const std::unique_ptr<A[], Deleter<A[]> > p2(new A[3]);
65 assert(!(p1 == p2));
66 assert(p1 != p2);
67 }
68 {
69 const std::unique_ptr<A[], Deleter<A[]> > p1(new A[3]);
70 const std::unique_ptr<B[], Deleter<B[]> > p2(new B[3]);
71 assert(!(p1 == p2));
72 assert(p1 != p2);
73 }
74 {
75 const std::unique_ptr<A, Deleter<A> > p1;
76 const std::unique_ptr<A, Deleter<A> > p2;
77 assert(p1 == p2);
78 assert(!(p1 != p2));
79 }
80 {
81 const std::unique_ptr<A, Deleter<A> > p1;
82 const std::unique_ptr<B, Deleter<B> > p2;
83 assert(p1 == p2);
84 assert(!(p1 != p2));
85 }
86
87 return 0;
88 }
89