DIP: add Bit Fields
ryuukk_
ryuukk.dev at gmail.com
Thu Mar 7 11:42:08 UTC 2024
On Thursday, 7 March 2024 at 04:26:56 UTC, Walter Bright wrote:
> https://github.com/WalterBright/documents/blob/master/bitfields.md
Have you ever thought of the idea of using bit specific integers?
I once saw this one suggestion on the IRC channel: `alias i1 =
__traits(integer, signed: false, 1);`
```D
alias u1 = __traits(integer, true, 1);
alias u3 = __traits(integer, true, 3);
alias u5 = __traits(integer, true, 5);
align(1) struct S
{
u1 isnothrow; // nothrow
u1 isnogc; // is @nogc
u1 isproperty; // can be called without parentheses
u1 isref; // returns a reference
u1 isreturn; // 'this' is returned by ref
u1 isscope; // 'this' is scope
u1 isreturninferred; // 'this' is return from inference
u1 isscopeinferred; // 'this' is scope from inference
u1 islive; // is @live
u1 incomplete; // return type or default arguments
removed
u1 inoutParam; // inout on the parameters
u1 inoutQual; // inout on the qualifier
u5 a;
u3 flags;
}
```
More information about the dip.development
mailing list