Bitfield accessors
Jarrett Billingsley
kb3ctd2 at yahoo.com
Tue Nov 20 06:36:38 PST 2007
"bearophile" <bearophileHUGS at lycos.com> wrote in message
news:fhufar$2hu$1 at digitalmars.com...
> Thank you very much Jarrett Billingsley, that's even better. I'll use a
> modified version of it in my code (with your name attached). Lately I tend
> to use compile-time functions more than templates, because I think they
> are a bit more readable. I have added another test, on the sum of the lens
> to see if they are equal to data.sizeof*8, because I like to avoid bugs
> all the times it's possible:
Cool :)
> Currently I am writing the module tests for Bitfield(), to see if it works
> when data is a ubyte/ushort/ulong too.
> I don't know if I'll need to make it optimize some the produced code,
> probably the compiler is enough to optimize it in most cases.
> I'd also like to do some speed comparison with the bitfields management of
> GCC.
If you're using it in a struct, I'd be very surprised if the call weren't
optimized out, in which case I'd expect the performance to be about the same
as C bitfields.
More information about the Digitalmars-d-learn
mailing list