bit fields
Timon Gehr
timon.gehr at gmx.ch
Tue Aug 31 00:06:12 UTC 2021
On 28.08.21 10:20, Walter Bright wrote:
>
> There are other advantages, too. I often use bit flags:
>
> enum Flags { A = 1, B = 2, C = 4, D = 8 }
>
> Flags f;
> f |= Flags.A;
> f &= ~Flags.B;
>
> but this is tedious, and so this often just winds up as:
>
> bool a, b, c, d;
>
> which is expensive in memory. With bit fields it is:
>
> bool a:1, b:1, c:1, d:1;
+1. This is one of those things you leave in to fix later because the
syntax is more convenient, then it does not get fixed later.
More information about the Digitalmars-d
mailing list