On Wednesday, July 18, 2012 10:43:23 Andrea Fontana wrote:
> So:
> const(int) : int <-- true
const int is implicitly convertible to int, because it's a value type, and
assigning a const int to an int (or vice versa) makes a copy.
> const(PP) : PP <-- false
const PP is not implicitly convertib
It seems to works (but i use Unqual!T directly)
Thank you :)
Il giorno mer, 18/07/2012 alle 11.13 +0200, bearophile ha scritto:
> 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 d
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)?
Run this code:
class PP {}
void what(T)(T val)
{
static if (is(T == int)) writeln ("T == int");
static if (is(T == const(int))) writeln ("T == const(int)");
static if (is(T : int)) writeln ("T : int");
static if (is(T == PP)) writeln ("T == PP");
static if