Paste: clay unions

Author: j
Mode: text
Date: Sat, 24 Apr 2010 23:55:35
Plain Text |
overloadable maxTypeSize;
[T, ...] maxTypeSize(static T, ...) = max(TypeSize(T), maxTypeSize(...));
[T] maxTypeSize(static T) = TypeSize(T);

record Union[...] {
    data : Array[UByte, maxTypeSize(...)];
}

unionAs(u : U, static T) { returnref Pointer[T](&u.data)^; }

New Annotation

Summary:
Author:
Mode:
Body: