xxxxxxxxxx
// 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;
}
auto static_map_tf(alias F)(immutable NewTypeInfo[] types...)
{
typeof(F(types[0]))[] result;
result.length = types.length;
foreach(i, t; types)
{
result[i] = F(t);
}
return result;
}
static assert(static_map_tf!(t => t.tsize)(__typeid!int, __typeid!ushort) == [4, 2]);
void main() {}