How to get the pointer of "this" ?

John Burton john.burton at jbmail.com
Mon May 25 17:54:39 UTC 2020


On Monday, 25 May 2020 at 16:39:30 UTC, Mike Parker wrote:
> On Monday, 25 May 2020 at 08:39:23 UTC, John Burton wrote:
>
>> I believe that in D *this* is a reference to the
>> object and not a pointer like in C++.
>> So I think that writing &this might be what you need?
>
> No. A class reference is a pointer under the hood. Getting its 
> address will result in a pointer to the reference variable 
> itself, not to the class instance. When passing a reference to 
> a C API, casting it directly to the C type is correct.

Ah I see.
In that case I have some code I need to investigate as it's 
probably only working by accident!


More information about the Digitalmars-d-learn mailing list