diff --git a/Utilities/typemap.h b/Utilities/typemap.h index e7d36e730b..c8a9019e2f 100644 --- a/Utilities/typemap.h +++ b/Utilities/typemap.h @@ -128,6 +128,19 @@ namespace utils static_assert(std::has_virtual_destructor_v>); }; + // Detect operator -> + template + struct typeinfo_pointer + { + static constexpr bool is_ptr = false; + }; + + template + struct typeinfo_pointer::operator->)>> + { + static constexpr bool is_ptr = true; + }; + // Type information struct typeinfo_base { @@ -469,7 +482,15 @@ namespace utils auto operator->() const noexcept { - return get(); + // Invoke object's operator -> if available + if constexpr (typeinfo_pointer::is_ptr) + { + return get()->operator->(); + } + else + { + return get(); + } } // Release the lock and set invalid state