mirror of
https://github.com/geode-sdk/geode.git
synced 2024-11-14 19:15:05 -05:00
Yeet safe_cast
This commit is contained in:
parent
7b2051d0b6
commit
4ac52b11d2
2 changed files with 1 additions and 11 deletions
|
@ -62,14 +62,4 @@ namespace geode::cast {
|
|||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Cast based on RTTI. This behaves as a replacement
|
||||
* of dynamic_cast for cocos and gd classes,
|
||||
* and must be used for expected results.
|
||||
*/
|
||||
template <class T, class F>
|
||||
static T safe_cast(F const obj) {
|
||||
return typeinfo_cast<T>(obj);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -743,7 +743,7 @@ namespace geode::cocos {
|
|||
*/
|
||||
template <class Type = cocos2d::CCNode>
|
||||
Type* findFirstChildRecursive(cocos2d::CCNode* node, utils::MiniFunction<bool(Type*)> predicate) {
|
||||
if (cast::safe_cast<Type*>(node) && predicate(static_cast<Type*>(node)))
|
||||
if (cast::typeinfo_cast<Type*>(node) && predicate(static_cast<Type*>(node)))
|
||||
return static_cast<Type*>(node);
|
||||
|
||||
auto children = node->getChildren();
|
||||
|
|
Loading…
Reference in a new issue