pointer to object resolution

Alex sascha.orlov at gmail.com
Fri May 11 21:35:01 UTC 2018


On Friday, 11 May 2018 at 15:24:08 UTC, Steven Schveighoffer 
wrote:
> On 5/11/18 8:53 AM, Alex wrote:
>
>> 
>> This behaves differently, w.r.t. to an arbitrary method, like 
>> "operator". Why? Is there any workaround?
>
> operators don't follow pointers.
>
> Imagine if you had a struct that overloads "+" and then you 
> wanted to use pointer arithmetic, but instead it called 
> ptr.opBinary.

Ah!

> The workaround is to dereference the pointer. e.g. 42 in *sptr;
>
> -Steve

Thanks a lot!


More information about the Digitalmars-d-learn mailing list