@@ -37,27 +37,27 @@ struct CombineVersions<VersionList<Version1, Versions1...>, VersionList<Version2
37
37
{
38
38
};
39
39
40
- template <template <int > typename Self , typename Versions>
40
+ template <typename Self, template <int > typename Multi , typename Versions>
41
41
struct CrossBuildVisitor
42
42
{
43
43
template <typename Visitor>
44
- static inline decltype (auto ) Visit(void * ptr, Visitor&& vis)
44
+ static inline decltype (auto ) Visit(Self * ptr, Visitor&& vis)
45
45
{
46
46
return Visit (ptr, std::forward<Visitor>(vis), xbr::GetGameBuild (), Versions{});
47
47
}
48
48
49
49
template <int Version, typename Visitor>
50
- static inline decltype (auto ) Visit(void * ptr, Visitor&& vis, int /* version*/ , VersionList<Version>)
50
+ static inline decltype (auto ) Visit(Self * ptr, Visitor&& vis, int /* version*/ , VersionList<Version>)
51
51
{
52
- return vis (static_cast <Self <Version>*>(ptr));
52
+ return vis (reinterpret_cast <Multi <Version>*>(ptr));
53
53
}
54
54
55
55
template <int Version1, int Version2, int ... ExtraVersions, typename Visitor>
56
- static inline decltype (auto ) Visit(void * ptr, Visitor&& vis, int version, VersionList<Version1, Version2, ExtraVersions...>)
56
+ static inline decltype (auto ) Visit(Self * ptr, Visitor&& vis, int version, VersionList<Version1, Version2, ExtraVersions...>)
57
57
{
58
58
if (version < Version2)
59
59
{
60
- return vis (static_cast <Self <Version1>*>(ptr));
60
+ return vis (reinterpret_cast <Multi <Version1>*>(ptr));
61
61
}
62
62
63
63
return Visit (ptr, std::forward<Visitor>(vis), version, VersionList<Version2, ExtraVersions...>{});
@@ -71,18 +71,7 @@ template<typename Self, template<int Version> typename Multi, typename _Versions
71
71
struct CrossBuildStructInfoBase
72
72
{
73
73
using Versions = _Versions;
74
- using Visitor = CrossBuildVisitor<Multi, Versions>;
75
-
76
- template <typename ... Args>
77
- static inline decltype (auto ) Create(Args&&... args)
78
- {
79
- return static_cast <Self*>(Visitor::Visit (nullptr , [&](auto p)
80
- {
81
- using RuntimeType = typename std::remove_pointer<decltype (p)>::type;
82
-
83
- return static_cast <void *>(new RuntimeType (std::forward<Args>(args)...));
84
- }));
85
- }
74
+ using Visitor = CrossBuildVisitor<Self, Multi, Versions>;
86
75
};
87
76
88
77
template <typename Self, template <int Version> typename Multi, int ... Versions>
@@ -110,7 +99,7 @@ inline decltype(auto) operator->*(Self* self, Func&& func)
110
99
}
111
100
112
101
template <typename T, typename ... Args>
113
- static inline decltype ( auto ) CrossBuildNew (Args&&... args)
102
+ static inline T* xbr_new (Args&&... args)
114
103
{
115
104
return static_cast <T*>(nullptr )->*[&](auto p)
116
105
{
@@ -121,12 +110,15 @@ static inline decltype(auto) CrossBuildNew(Args&&... args)
121
110
}
122
111
123
112
template <typename T>
124
- static inline decltype ( auto ) CrossBuildDelete (T* ptr)
113
+ static inline void xbr_delete (T* ptr)
125
114
{
126
- ptr->*[]( auto self )
115
+ if (ptr )
127
116
{
128
- delete self;
129
- };
117
+ ptr->*[](auto self)
118
+ {
119
+ delete self;
120
+ };
121
+ }
130
122
}
131
123
132
124
#define XBV (...) \
0 commit comments