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 convertible to PP, because it's a reference type. So, assigning a PP to a PP doesn't make a copy. It just copies the reference. And a const PP can't be converted to a mutable PP, because that would be dropping the const, invalidating const's guarantees. If PP were a struct with no pointers, arrays, or reference types (or it had a postblit constructor), then it would be a value type, and const PP _would_ implicitly convert to PP. > Is this behaviour correct? Yes. > And how can I check if T is of a certain class ignoring consts (and > avoiding double checks)? is(Unqual!T == T) Unqual is in std.traits. - Jonathan M Davis