Type constructor with new size

Seb via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat Jul 16 13:17:11 PDT 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


More information about the Digitalmars-d-learn mailing list