digitalmars.D.learn - Type constructor with new size
How can I create a new type NT from type T that such that NT is compatible with T when reduced to the size of T, but has size n? Another way to see it is that I would like to construct a type at compile time that has the same layout as another type but padded exactly by n - T.sizeof bytes. It would be nice if the new type is implicitly convertible to T. This should be automatic and exact without overhead(pure, if you will).
Jul 14 2016
On Friday, 15 July 2016 at 01:10:09 UTC, Eppason wrote:How can I create a new type NT from type T that such that NT is compatible with T when reduced to the size of T, but has size n? Another way to see it is that I would like to construct a type at compile time that has the same layout as another type but padded exactly by n - T.sizeof bytes. It would be nice if the new type is implicitly convertible to T. This should be automatic and exact without overhead(pure, if you will).Hi, I am not sure what underlying problem you are trying to solve and maybe you could try to explain this? You can always create a templated Wrapper struct, but again I am not sure why you would want to do this without a use case
Jul 16 2016