Report a bug
If you spot a problem with this page, click here to create a Bugzilla issue.
Improve this page
Quickly fork, edit online, and submit a pull request for this page.
Requires a signed-in GitHub account. This works well for small changes.
If you'd like to make larger changes you may want to consider using
a local clone.
dmd.common.bitfields
A library bitfields utility
Authors:
Dennis Korpel
License:
Source common/bitfields.d
Coverage https://codecov.io/gh/dlang/dmd/src/master/src/dmd/common/bitfields.d
- string
generateBitFields
(S, T)()
if (__traits(isUnsigned, T)); - Generate code for bit fields inside a struct/class bodyParameters:
S type of a struct with only boolean fields, which should become bit fields T type of bit fields variable, must have enough bits to store all booleans Returns:D code with a bit fields variable and getter / setter functionsExamples:static struct B { bool x; bool y; bool z = 1; } static struct S { mixin(generateBitFields!(B, ubyte)); } S s; assert(!s.x); s.x = true; assert(s.x); s.x = false; assert(!s.x); s.y = true; assert(s.y); assert(!s.x); assert(s.z);
Copyright © 1999-2024 by the D Language Foundation | Page generated by
Ddoc on Tue Nov 19 00:23:29 2024