mirror of
https://github.com/geode-sdk/geode.git
synced 2024-11-14 19:15:05 -05:00
move typeinfo_pointer_cast to a cross-platform header
This commit is contained in:
parent
f061dd4bf2
commit
28cc6fdbd3
2 changed files with 10 additions and 7 deletions
|
@ -242,3 +242,13 @@ namespace std {
|
||||||
#elif defined(GEODE_IS_ANDROID64)
|
#elif defined(GEODE_IS_ANDROID64)
|
||||||
#define GEODE_PLATFORM_TARGET PlatformID::Android64
|
#define GEODE_PLATFORM_TARGET PlatformID::Android64
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// this is cross-platform so not duplicating it across the typeinfo_cast definitions
|
||||||
|
namespace geode::cast {
|
||||||
|
template<class T, class U>
|
||||||
|
std::shared_ptr<T> typeinfo_pointer_cast(std::shared_ptr<U> const& r) noexcept {
|
||||||
|
// https://en.cppreference.com/w/cpp/memory/shared_ptr/pointer_cast
|
||||||
|
auto p = typeinfo_cast<typename std::shared_ptr<T>::element_type*>(r.get());
|
||||||
|
return std::shared_ptr<T>(r, p);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -130,11 +130,4 @@ namespace geode::cast {
|
||||||
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T, class U>
|
|
||||||
std::shared_ptr<T> typeinfo_pointer_cast(std::shared_ptr<U> const& r) noexcept {
|
|
||||||
// https://en.cppreference.com/w/cpp/memory/shared_ptr/pointer_cast
|
|
||||||
auto p = typeinfo_cast<typename std::shared_ptr<T>::element_type*>(r.get());
|
|
||||||
return std::shared_ptr<T>(r, p);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue