setTypeInfo???
bearophile
bearophileHUGS at lycos.com
Sun Aug 31 03:42:43 PDT 2008
Sorry for spamming the newsgroup, I am not there yet. The original IsArray template was correct, because is uses a kind of static duck typing :-) So to solve your bug I have modified IsReferenceType!() like this:
template IsReferenceType(Types...) {
static if (Types.length == 0) {
const bool IsReferenceType = false;
} else static if (Types.length == 1) {
// dsimcha suggests to replace the following line with
// static if (IsType!(Mutable!(Types[0]), bool, byte, ...
// to make this template work with const/immutable types on D 2.x.
static if (IsType!(Types[0], bool, byte, ubyte, short, ushort, int, uint,
long, ulong, float, double, real, ifloat, idouble,
ireal, cfloat, cdouble, creal, char, dchar, wchar) ) {
const bool IsReferenceType = false;
} else static if ( is(Types[0] == class) ) {
const bool IsReferenceType = true;
} else static if ( is(Types[0] == struct) ) {
const bool IsReferenceType = IsReferenceType!(FieldTypeTuple!(Types[0]));
} else static if (IsStaticArray!(Types[0])) {
const bool IsReferenceType = IsReferenceType!(ArrayType1!(Types[0]));
} else
const bool IsReferenceType = true;
} else
const bool IsReferenceType = IsReferenceType!(Types[0]) |
IsReferenceType!(Types[1 .. $]);
} // end IsReferenceType!()
Bye,
bearophile
More information about the Digitalmars-d
mailing list