Pointer types [Was: Re: Lints, Condate and bugs]

bearophile bearophileHUGS at lycos.com
Sun Oct 31 17:11:25 PDT 2010


Walter:

> > - @single: this pointer is either null or points to a single element of the
> > base type (this disallows the indexing [] syntax).
> 
> ref T single = *p;

Is this a D syntax or C++ syntax? I have never seen this used in D unless as function argument.


> > - @bound(hi,lo): this pointer is either null or points inside an array of
> > given lower and upper bounds.
> 
> T[] bound = p[lo..hi];

I was talking about a (fat) pointer, something you may move forward and backward, assign, deferentiate, you may perform arithmetic on it, etc. This is why I have written in my post:
static assert(BoundPtr!int.sizeof == (size_t.sizeof * 3));


> > - @sentinel: this pointer is useful only for comparisons and not for
> > dereference or indexing. This annotation is usually used for pointers that
> > point immediately after an allocated area.
> 
> T[] sentinel = p[0..0];

That's not a pointer.

Bye,
bearophile


More information about the Digitalmars-d mailing list