Movatterモバイル変換


[0]ホーム

URL:


D Logo
Menu
Search

Library Reference

version 2.112.0

overview

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 usinga local clone.

dmd.common.bitfields

A library bitfields utility
Authors:
Dennis Korpel
License:
Boost License 1.0

Sourcecommon/bitfields.d

Documentationhttps://dlang.org/phobos/dmd_common_bitfields.html

Coveragehttps://codecov.io/gh/dlang/dmd/src/master/compiler/src/dmd/common/bitfields.d

stringgenerateBitFields(S, T, string field = "", int bitOff = 0, int ID = __LINE__)()
if (__traits(isUnsigned, T));
Generate code for bit fields inside a struct/class body
Parameters:
Stype of a struct with only boolean fields, which should become bit fields
Ttype of bit fields variable, must have enough bits to store all booleans
fieldif provided, assume it is declared and initialized elsewhere
bitOffstart using bits at the given offset
Returns:
D code with a bit fields variable and getter / setter functions
Examples:
enum E{    a, b, c,}staticstruct B{bool x;bool y;    E e = E.c;bool z = 1;privateubyte w = 77;}staticstruct S{mixin(generateBitFields!(B,ushort));}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.e == E.c);s.e = E.a;assert(s.e == E.a);assert(s.z);assert(s.w == 77);s.w = 3;assert(s.w == 3);
Copyright © 1999-2026 by theD Language Foundation | Page generated byDdoc on Fri Feb 20 00:51:04 2026

[8]ページ先頭

©2009-2026 Movatter.jp