1
0
mirror of https://github.com/RPCS3/rpcs3.git synced 2025-01-31 20:41:45 +01:00

typemap: improve pointer support

If stored object is a pointer, access dereferenced object directly via ->
This commit is contained in:
Nekotekina 2019-02-01 23:11:23 +03:00
parent 240ba39d16
commit 6c5d9fffaa

View File

@ -128,6 +128,19 @@ namespace utils
static_assert(std::has_virtual_destructor_v<std::decay_t<T>>); static_assert(std::has_virtual_destructor_v<std::decay_t<T>>);
}; };
// Detect operator ->
template <typename T, typename = void>
struct typeinfo_pointer
{
static constexpr bool is_ptr = false;
};
template <typename T>
struct typeinfo_pointer<T, std::void_t<decltype(&std::decay_t<T>::operator->)>>
{
static constexpr bool is_ptr = true;
};
// Type information // Type information
struct typeinfo_base struct typeinfo_base
{ {
@ -469,7 +482,15 @@ namespace utils
auto operator->() const noexcept auto operator->() const noexcept
{ {
return get(); // Invoke object's operator -> if available
if constexpr (typeinfo_pointer<T>::is_ptr)
{
return get()->operator->();
}
else
{
return get();
}
} }
// Release the lock and set invalid state // Release the lock and set invalid state