Date: Sat, 07 Jun 2025 14:53:00 -0300
On Saturday, 7 June 2025 13:39:21 Brasilia Standard Time Frederick Virchanza
Gotham via Std-Proposals wrote:
> I searched and searched and searched for a way to get the
> 'RTTICompleteObjectLocator' for a type, but Microsoft hasn't
> documented it publicly. My spidey senses are telling me though that
> they probably have their own secret operator something like
> '__get_rtti_complete_object_locator(T)'. They must have.
Correct, kinda. For a given type T, the compiler knows where it put the
locator as an offset from the top of the object. That need not be available as
an intrinsic to compiled code, however. It's just something the compiler
knows, like it had known the offset of members inside of structures decades
before the existence of pointers to data members.
But if you know what the type is, you could just static_cast to it. Problem
solved. There's no type erasure.
> So I was thinking . . . if I could somehow intercept an invocation of
> '__RTCastToVoid', then I could compare my object pointer to the
> pointer that gets passed to __RTCastToVoid.
Completely irrelevant information. Stop going down this line of investigation
of how *you* could do it. *You* are not the one to do it. If this becomes a
functionality of the core language or of the standard library, *Microsoft*
would implement it and they can just modify the compiler to make it happen.
Gotham via Std-Proposals wrote:
> I searched and searched and searched for a way to get the
> 'RTTICompleteObjectLocator' for a type, but Microsoft hasn't
> documented it publicly. My spidey senses are telling me though that
> they probably have their own secret operator something like
> '__get_rtti_complete_object_locator(T)'. They must have.
Correct, kinda. For a given type T, the compiler knows where it put the
locator as an offset from the top of the object. That need not be available as
an intrinsic to compiled code, however. It's just something the compiler
knows, like it had known the offset of members inside of structures decades
before the existence of pointers to data members.
But if you know what the type is, you could just static_cast to it. Problem
solved. There's no type erasure.
> So I was thinking . . . if I could somehow intercept an invocation of
> '__RTCastToVoid', then I could compare my object pointer to the
> pointer that gets passed to __RTCastToVoid.
Completely irrelevant information. Stop going down this line of investigation
of how *you* could do it. *You* are not the one to do it. If this becomes a
functionality of the core language or of the standard library, *Microsoft*
would implement it and they can just modify the compiler to make it happen.
-- Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org Principal Engineer - Intel Platform & System Engineering
Received on 2025-06-07 17:53:03