forked from flutter/engine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdisplay_list_comparable.h
116 lines (92 loc) · 2.75 KB
/
display_list_comparable.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef FLUTTER_DISPLAY_LIST_DISPLAY_LIST_COMPARABLE_H_
#define FLUTTER_DISPLAY_LIST_DISPLAY_LIST_COMPARABLE_H_
#include "flutter/display_list/types.h"
namespace flutter {
// These templates implement deep pointer comparisons that compare not
// just the pointers to the objects, but also their contents (provided
// that the <T> class implements the == operator override).
// Any combination of shared_ptr<T> or T* are supported and null pointers
// are not equal to anything but another null pointer.
template <class T>
bool Equals(const T* a, const T* b) {
if (a == b) {
return true;
}
if (!a || !b) {
return false;
}
return *a == *b;
}
template <class T>
bool Equals(std::shared_ptr<const T> a, const T* b) {
return Equals(a.get(), b);
}
template <class T>
bool Equals(std::shared_ptr<T> a, const T* b) {
return Equals(a.get(), b);
}
template <class T>
bool Equals(const T* a, std::shared_ptr<const T> b) {
return Equals(a, b.get());
}
template <class T>
bool Equals(const T* a, std::shared_ptr<T> b) {
return Equals(a, b.get());
}
template <class T>
bool Equals(std::shared_ptr<const T> a, std::shared_ptr<const T> b) {
return Equals(a.get(), b.get());
}
template <class T>
bool Equals(std::shared_ptr<T> a, std::shared_ptr<const T> b) {
return Equals(a.get(), b.get());
}
template <class T>
bool Equals(std::shared_ptr<const T> a, std::shared_ptr<T> b) {
return Equals(a.get(), b.get());
}
template <class T>
bool Equals(std::shared_ptr<T> a, std::shared_ptr<T> b) {
return Equals(a.get(), b.get());
}
template <class T>
bool NotEquals(const T* a, const T* b) {
return !Equals<T>(a, b);
}
template <class T>
bool NotEquals(std::shared_ptr<const T> a, const T* b) {
return !Equals(a.get(), b);
}
template <class T>
bool NotEquals(std::shared_ptr<T> a, const T* b) {
return !Equals(a.get(), b);
}
template <class T>
bool NotEquals(const T* a, std::shared_ptr<const T> b) {
return !Equals(a, b.get());
}
template <class T>
bool NotEquals(const T* a, std::shared_ptr<T> b) {
return !Equals(a, b.get());
}
template <class T>
bool NotEquals(std::shared_ptr<const T> a, std::shared_ptr<const T> b) {
return !Equals(a.get(), b.get());
}
template <class T>
bool NotEquals(std::shared_ptr<T> a, std::shared_ptr<const T> b) {
return !Equals(a.get(), b.get());
}
template <class T>
bool NotEquals(std::shared_ptr<const T> a, std::shared_ptr<T> b) {
return !Equals(a.get(), b.get());
}
template <class T>
bool NotEquals(std::shared_ptr<T> a, std::shared_ptr<T> b) {
return !Equals(a.get(), b.get());
}
} // namespace flutter
#endif // FLUTTER_DISPLAY_LIST_DISPLAY_LIST_COMPARABLE_H_