Skip to content

Commit

Permalink
weakref hash from sleepyut
Browse files Browse the repository at this point in the history
  • Loading branch information
altalk23 committed Sep 10, 2024
1 parent 67814ec commit 2d9ce8f
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions loader/include/Geode/utils/cocos.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,9 @@ namespace geode {

WeakRef(std::shared_ptr<WeakRefController> obj) : m_controller(obj) {}

friend class std::hash<WeakRef<T>>;


public:
/**
* Construct a WeakRef of an object. A weak reference is one that will
Expand Down Expand Up @@ -972,6 +975,13 @@ namespace std {
return std::hash<T*>()(ref.data());
}
};

template <typename T>
struct std::hash<geode::WeakRef<T>> {
size_t operator()(geode::WeakRef<T> const& ref) const {
return hash{}(ref.m_controller);
}
};
}

// more utils
Expand Down

0 comments on commit 2d9ce8f

Please sign in to comment.