Detect 8-bit alligned type TXY by TX,TY.
Imperatorn
johan_forsberg_86 at hotmail.com
Thu Sep 21 17:28:33 UTC 2023
On Tuesday, 19 September 2023 at 06:41:49 UTC, Vitaliy Fadeev
wrote:
> On Tuesday, 19 September 2023 at 06:33:25 UTC, Richard (Rikki)
> Andrew Cattermole wrote:
>> [...]
>
> Thank, Richard.
>
> ```.offsetof...``` mmm...
>
> May be exists some like:
>
> ```d
> // TXYXY = Detect!(TX,TX)
> // Detect!(uint,uint) == ulong
> template Detect(TX,TY)
> {
> static if ( TX.sizeof + TY.sizeof <= 8 )
> alias Detect = ubyte;
> else
> static if ( TX.sizeof + TY.sizeof <= 16 )
> alias Detect = ushort;
> else
> static if ( TX.sizeof + TY.sizeof <= 32 )
> alias Detect= uint;
> else
> static if ( TX.sizeof + TY.sizeof <= 64 )
> alias Detect= ulong;
> else
> static if ( TX.sizeof + TY.sizeof <= 128 )
> alias Detect= ucent;
> else
> static assert( 0, "Expected size TX+TY <= 128" );
> }
> ```
Do a mixin
More information about the Digitalmars-d-learn
mailing list