File tree Expand file tree Collapse file tree 3 files changed +33
-7
lines changed
loader/include/Geode/platform Expand file tree Collapse file tree 3 files changed +33
-7
lines changed Original file line number Diff line number Diff line change 11#pragma once
22
3+ #include " _casts_shared.hpp"
4+
35namespace geode ::cast {
46
57 struct DummyClass {
@@ -102,10 +104,8 @@ namespace geode::cast {
102104
103105 template <class After , class Before >
104106 inline After typeinfo_cast (Before ptr) {
105- static_assert (
106- std::is_polymorphic_v<std::remove_pointer_t <Before>> && std::is_polymorphic_v<std::remove_pointer_t <After>>,
107- " Input is not a polymorphic type"
108- );
107+ ::geode::geode_internal::typeinfoCastChecks<After, Before>();
108+
109109 if (!ptr) {
110110 return static_cast <After>(nullptr );
111111 }
Original file line number Diff line number Diff line change 1+ #pragma once
2+
3+ #include < type_traits>
4+
5+ namespace geode {
6+ template <class Derived , class Base >
7+ class Modify ;
8+ }
9+
10+ namespace geode ::geode_internal {
11+ template <class D , class B >
12+ inline void dummyModifyFn (::geode::Modify<D, B> const &);
13+
14+ template <class T >
15+ concept IsModifyClass = requires (std::remove_pointer_t <T> const & a) { ::geode::geode_internal::dummyModifyFn (a); };
16+
17+ template <class After , class Before >
18+ inline constexpr void typeinfoCastChecks () {
19+ static_assert (
20+ std::is_polymorphic_v<std::remove_pointer_t <Before>> && std::is_polymorphic_v<std::remove_pointer_t <After>>,
21+ " Input is not a polymorphic type"
22+ );
23+
24+ static_assert (!geode_internal::IsModifyClass<After>,
25+ " typeinfo_cast will not work with a Modify class. use static_cast<MyModifyClass*>(typeinfo_cast<Class*>(...)) instead" );
26+ }
27+ }
Original file line number Diff line number Diff line change 1010#include < typeinfo>
1111#include < memory>
1212#include < intrin.h> // for _ReadWriteBarrier
13+ #include " _casts_shared.hpp"
1314
1415namespace geode {
1516 struct PlatformInfo {
@@ -121,9 +122,7 @@ namespace geode::cast {
121122
122123 template <class After , class Before >
123124 inline After typeinfo_cast (Before ptr) {
124- static_assert (
125- std::is_polymorphic_v<std::remove_pointer_t <Before>>, " Input is not a polymorphic type"
126- );
125+ ::geode::geode_internal::typeinfoCastChecks<After, Before>();
127126
128127 if (!ptr) {
129128 return After ();
You can’t perform that action at this time.
0 commit comments