July 15, 2016 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). |
July 16, 2016 Re: Type constructor with new size | ||||
---|---|---|---|---|
| ||||
Posted in reply to Eppason | 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
|
Copyright © 1999-2021 by the D Language Foundation