mirror of
https://github.com/LSPosed/LSPlant.git
synced 2025-05-04 20:42:02 +08:00
Add is_instance_v
This commit is contained in:
parent
89f10845c3
commit
752c85a030
@ -166,7 +166,7 @@ concept HookerType = requires(T a) {
|
||||
template<HookerType T>
|
||||
inline static bool HookSymNoHandle(const HookHandler &handler, void *original, T &arg) {
|
||||
if (original) {
|
||||
if constexpr(is_instance<decltype(arg.backup), MemberFunction>::value) {
|
||||
if constexpr(is_instance_v<decltype(arg.backup), MemberFunction>) {
|
||||
void *backup = handler.inline_hooker(original, reinterpret_cast<void *>(arg.replace));
|
||||
arg.backup = reinterpret_cast<typename decltype(arg.backup)::FunType>(backup);
|
||||
} else {
|
||||
|
@ -20,6 +20,9 @@ template<class...Ts, template<class, class...> class U>
|
||||
struct is_instance<U<Ts...>, U> : public std::true_type {
|
||||
};
|
||||
|
||||
template<class T, template<class, class...> class U>
|
||||
inline constexpr bool is_instance_v = is_instance<T, U>::value;
|
||||
|
||||
template<typename T>
|
||||
concept JObject = std::is_base_of_v<std::remove_pointer_t<_jobject>, std::remove_pointer_t<T>>;
|
||||
|
||||
@ -111,7 +114,7 @@ public:
|
||||
|
||||
template<typename T, typename U>
|
||||
concept ScopeOrRaw = std::is_convertible_v<T, U> ||
|
||||
(is_instance<std::decay_t<T>, ScopedLocalRef>::value &&
|
||||
(is_instance_v<std::decay_t<T>, ScopedLocalRef> &&
|
||||
std::is_convertible_v<typename std::decay_t<T>::BaseType, U>);
|
||||
|
||||
template<typename T>
|
||||
@ -138,7 +141,7 @@ template<typename T>
|
||||
inline auto UnwrapScope(T &&x) {
|
||||
if constexpr(std::is_same_v<std::decay_t<T>, std::string_view>)
|
||||
return x.data();
|
||||
else if constexpr(is_instance<std::decay_t<T>, ScopedLocalRef>::value)
|
||||
else if constexpr(is_instance_v<std::decay_t<T>, ScopedLocalRef>)
|
||||
return x.get();
|
||||
else return std::forward<T>(x);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user