What about C's -> ?

Chris Nicholson-Sauls ibisbasenji at gmail.com
Tue Jul 24 13:50:15 PDT 2007


Bill Baxter wrote:
> freeagle wrote:
>> Hoenir wrote:
>>> There seems to be no p->x in D. Is there any other syntactic sugar 
>>> for (*p).x ?
>>
>> dot operator stands for both dot and -> operators in c++
> 
> Just curious -- does it also work for (**p).x and (***p).x etc?
> (Sorry to lazy to check :-P )  But surely someone here knows right off 
> the top of their head.
> 
> --bb

As far as I recall, yes.  The '.' will "continuously" dereference until 
it hits something solid, and then offset appropriately from there. 
Although I rarely have had more than (*p) in my experience with D.  (And 
usually only with referencing elements from arrays of structures, and 
with using the 'in' operator on associative arrays.)

-- Chris Nicholson-Sauls


More information about the Digitalmars-d-learn mailing list