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