auto*

FoxyBrown via Digitalmars-d digitalmars-d at puremagic.com
Thu Jul 6 13:24:24 PDT 2017


On Thursday, 6 July 2017 at 18:11:13 UTC, H. S. Teoh wrote:
> On Thu, Jul 06, 2017 at 06:10:57PM +0000, FoxyBrown via 
> Digitalmars-d wrote:
>> Create an auto pointer, handy in some cases and fits in the 
>> language as a natural generalization.
>
> What's an auto pointer?
>
>
> T

is it not obvious?

auto x = ...

auto* x = ...

auto* is the pointerized version of auto.


e.g.,

int x = ...

int* x = ...

typeof(x) y = ...
typeof(x)* y = ...


obviously the rhs must be congruent with the type.

auto p = &foo;  // a pointer
auto* p = &foo; // a double pointer to foo.

When having the need to require a pointer to a pointer, it avoids 
having to specify the type in a verbose way.

i.e., the second line above is not valid, but to do it we must 
either cast to void** or use typeof and such to get the correct 
type and make a pointer out of it. auto* simplifies all that.




More information about the Digitalmars-d mailing list