What other than a pointer can be converted implicitly to const(char)*?

anonymous via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Dec 21 12:47:47 PST 2015


On 21.12.2015 21:20, Steven Schveighoffer wrote:
> This seems like an incorrect feature then. Why wouldn't I want S to be
> treated like any other const(char)*? Seems like it's explicitly saying
> "treat this like a const(char)*"

To my understanding, `alias this` means "is implicitly convertible to 
X", and not "is the same thing as X".

That is, `is(S == const(char)*)` is false, but `is(S : const(char)*)` is 
true. It makes sense to me that isPointer behaves like the `==` variant.

And for sure, the `alias this` doesn't make S interchangeable with a 
pointer. S may have a different size, the pointer may not be at a zero 
offset in S, etc.

For the phobos code in question it comes down to what's less surprising, 
I guess. Having such an `alias this` resolved before stringification, or 
not. I'm not sure.


More information about the Digitalmars-d-learn mailing list