Re: Type constructor with new size

2016-07-16 Thread Seb via Digitalmars-d-learn

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


Type constructor with new size

2016-07-14 Thread Eppason via Digitalmars-d-learn
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).