On Thu, Jul 06, 2017 at 08:24:24PM +0000, FoxyBrown via Digitalmars-d wrote: [...] > 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.
Huh? How is it even remotely valid to cast a single pointer to a double pointer implicitly? If foo is a non-pointer object, `auto p = &foo;` already gives you a pointer. If foo itself is also a pointer, `auto p = &foo;` will already give you a double pointer. There is no need to "specify the type in a verbose way" at all. You can't get a double pointer out of a single pointer without saving the single pointer in an addressable variable, e.g.: auto p = &foo; // takes address of foo (single pointer) auto pp = &p; // takes address of p (double pointer) It's invalid to take the address of an rvalue, because an rvalue has no location. I.e., `&(&foo)` is illegal because &foo is an rvalue. Before you can make a double pointer to it, you have to designate some location where it is to be stored, so that the double pointer can point to that location. T -- The two rules of success: 1. Don't tell everything you know. -- YHL