is() and const

bearophile bearophileHUGS at lycos.com
Wed Jul 18 02:13:37 PDT 2012


Andrea Fontana:

> const(int) : int  <-- true
> const(PP) : PP  <-- false
>
> Is this behaviour correct?

I think it's correct, and it's caused by the difference between 
value types and reference types.


> And how can I check if T is of a certain class ignoring consts 
> (and avoiding double checks)?

There are some different ways to do it, one of them is to use 
something like (untested):

is(Unqual!typeof(x) == PP)

Where Unqual is in Phobos, std.traits.Unqual.

Bye,
bearophile


More information about the Digitalmars-d-learn mailing list