xxxxxxxxxx
import std;
// Base class for CT and RT type information.
immutable abstract class NewTypeInfo {
size_t tsize();
}
// Implementation for given type T.
immutable class NewTypeInfoImpl(T) : NewTypeInfo {
override size_t tsize() {
return T.sizeof;
}
}
// Use __typeid!T to get a singleton object associated with type T.
immutable(NewTypeInfo) __typeid(T)() {
static immutable singleton = new NewTypeInfoImpl!T;
return singleton;
}
static assert([__typeid!int, __typeid!ushort].map!(t => t.tsize).equal([4, 2]));
void main() {}