is pointer

Moritz Warning moritzwarning at web.de
Fri Mar 19 17:53:43 PDT 2010


On Fri, 19 Mar 2010 19:29:24 -0400, bearophile wrote:

> (I am looking for rough corners in D, or in my knowledge of D.)
[..]
> 
> template IsPointer1(T) {
>     enum bool IsPointer1 = is(T : T*);
> }
> void main() {
>     int* ptr;
>     static assert(IsPointer1!(typeof(ptr))); // Err
> }
> 
> 
> But it asserts, do you know why?

I think the problem is that is(T : T*) becomes is(int* : int**)
and that's false.



> Then I have written a different program:
[..]
>     enum bool IsPointer2 = is(typeof(*T)) || is(T == void*);
[..]
> 
> 
> Do you know why IsPointer2 is true for the dynamic array type too?
.. no idea.


More information about the Digitalmars-d-learn mailing list