Skip to content

Commit 24f5c79

Browse files
authored
Add nullptr guard-check in comparision of shared ptr node and edge (#436)
* Add nullptr guard-check in comparision of shared ptr node and edge * Ran through git clang-format HEAD
1 parent d0ed187 commit 24f5c79

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

include/CXXGraph/Utility/PointerHash.hpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,16 +57,23 @@ struct edgeHash {
5757

5858
template <typename T>
5959
bool operator==(shared<const Node<T>> p1, shared<const Node<T>> p2) {
60+
if (p1 == nullptr && p2 == nullptr) return true;
61+
if (p1 == nullptr || p2 == nullptr) return false;
6062
return p1->getUserId() == p2->getUserId();
6163
}
6264

6365
template <typename T>
6466
bool operator==(shared<Node<T>> p1, shared<Node<T>> p2) {
67+
if (p1 == nullptr && p2 == nullptr) return true;
68+
if (p1 == nullptr || p2 == nullptr) return false;
6569
return p1->getUserId() == p2->getUserId();
6670
}
6771

6872
template <typename T>
6973
bool operator==(shared<const Edge<T>> p1, shared<const Edge<T>> p2) {
74+
if (p1 == nullptr && p2 == nullptr) return true;
75+
if (p1 == nullptr || p2 == nullptr) return false;
76+
7077
return p1->getNodePair().first->getUserId() ==
7178
p2->getNodePair().first->getUserId() &&
7279
p1->getNodePair().second->getUserId() ==

0 commit comments

Comments
 (0)