Skip to content

Commit 29d4643

Browse files
committed
add Ref::adopt
1 parent d8cd5c4 commit 29d4643

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

loader/include/Geode/utils/cocos.hpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,17 @@ namespace geode {
257257
*/
258258
Ref() = default;
259259

260+
/**
261+
* Construct a Ref of an object, without retaining it.
262+
* The object will still be released when Ref goes out of scope.
263+
* @param obj Object to construct the Ref from
264+
*/
265+
static Ref<T> adopt(T* obj) {
266+
Ref<T> ref;
267+
ref.m_obj = obj;
268+
return ref;
269+
}
270+
260271
~Ref() {
261272
CC_SAFE_RELEASE(m_obj);
262273
}

0 commit comments

Comments
 (0)