From 28cc6fdbd307a64787aa13e5dae3e9c69a9286f8 Mon Sep 17 00:00:00 2001 From: HJfod <60038575+HJfod@users.noreply.github.com> Date: Tue, 20 Aug 2024 12:50:20 +0300 Subject: [PATCH] move typeinfo_pointer_cast to a cross-platform header --- loader/include/Geode/platform/platform.hpp | 10 ++++++++++ loader/include/Geode/platform/windows.hpp | 7 ------- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/loader/include/Geode/platform/platform.hpp b/loader/include/Geode/platform/platform.hpp index afca28da..b4c5bf71 100644 --- a/loader/include/Geode/platform/platform.hpp +++ b/loader/include/Geode/platform/platform.hpp @@ -242,3 +242,13 @@ namespace std { #elif defined(GEODE_IS_ANDROID64) #define GEODE_PLATFORM_TARGET PlatformID::Android64 #endif + +// this is cross-platform so not duplicating it across the typeinfo_cast definitions +namespace geode::cast { + template + std::shared_ptr typeinfo_pointer_cast(std::shared_ptr const& r) noexcept { + // https://en.cppreference.com/w/cpp/memory/shared_ptr/pointer_cast + auto p = typeinfo_cast::element_type*>(r.get()); + return std::shared_ptr(r, p); + } +} diff --git a/loader/include/Geode/platform/windows.hpp b/loader/include/Geode/platform/windows.hpp index 374e0e1e..ee22e0d3 100644 --- a/loader/include/Geode/platform/windows.hpp +++ b/loader/include/Geode/platform/windows.hpp @@ -130,11 +130,4 @@ namespace geode::cast { return nullptr; } - - template - std::shared_ptr typeinfo_pointer_cast(std::shared_ptr const& r) noexcept { - // https://en.cppreference.com/w/cpp/memory/shared_ptr/pointer_cast - auto p = typeinfo_cast::element_type*>(r.get()); - return std::shared_ptr(r, p); - } }