Jump to: bitfields FloatRep DoubleRep BitArray opIndex opIndexAssign dup opApply reverse sort opEquals opCmp init opCast opCom opAnd opOr opXor opSub opAndAssign opOrAssign opXorAssign opSubAssign opCatAssign opCat opCat_r
Bit-level manipulation facilities.
Authors:
Walter Bright, Andrei Alexandrescu
template bitfields(T...)
Allows creating bit fields inside structs and classes.
Example:
struct A
{
int a;
mixin(bitfields!(
uint, "x", 2,
int, "y", 3,
uint, "z", 2,
bool, "flag", 1));
}
A obj;
obj.x = 2;
obj.z = obj.x;
The example above creates a bitfield pack of eight bits, which fit in one ubyte. The bitfields are allocated starting from the least significant bit, i.e. x occupies the two least significant bits of the bitfields storage.
The sum of all bit lengths in one bitfield instantiation must be exactly 8, 16, 32, or 64. If padding is needed, just allocate one bitfield with an empty name.
Example:
struct A
{
mixin(bitfields!(
bool, "flag1", 1,
bool, "flag2", 1,
uint, "", 6));
}
The type of a bit field can be any integral type or enumerated type. The most efficient type to store in bitfields is bool, followed by unsigned types, followed by signed types.
struct FloatRep;
Allows manipulating the fraction, exponent, and sign parts of a float separately. The definition is:
struct FloatRep
{
union
{
float value;
mixin(bitfields!(
uint, "fraction", 23,
ubyte, "exponent", 8,
bool, "sign", 1));
}
}
struct DoubleRep;
Allows manipulating the fraction, exponent, and sign parts of a double separately. The definition is:
struct DoubleRep
{
union
{
double value;
mixin(bitfields!(
ulong, "fraction", 52,
ushort, "exponent", 11,
bool, "sign", 1));
}
}
struct BitArray;
An array of bits.
const bool opIndex(size_t i);
bool opIndexAssign(bool b, size_t i);
Support for [index] operation for BitArray.
BitArray dup();
Support for array.dup property for BitArray.
int opApply(int delegate(ref bool) dg);
int opApply(int delegate(ref uint, ref bool) dg);
Support for foreach loops for BitArray.
BitArray reverse();
Support for array.reverse property for BitArray.
BitArray sort();
Support for array.sort property for BitArray.
int opEquals(BitArray a2);
Support for operators == and != for bit arrays.
int opCmp(BitArray a2);
Implement comparison operators.
void init(bool[] ba);
Set BitArray to contents of ba[]
void init(void[] v, size_t numbits);
Map BitArray onto v[], with numbits being the number of bits in the array. Does not copy the data.
This is the inverse of opCast.
void[] opCast();
Convert to void[].
BitArray opCom();
Support for unary operator ~ for bit arrays.
BitArray opAnd(BitArray e2);
Support for binary operator & for bit arrays.
BitArray opOr(BitArray e2);
Support for binary operator | for bit arrays.
BitArray opXor(BitArray e2);
Support for binary operator ^ for bit arrays.
BitArray opSub(BitArray e2);
Support for binary operator - for bit arrays.
a - b for BitArrays means the same thing as a & ~b.
BitArray opAndAssign(BitArray e2);
Support for operator &= bit arrays.
BitArray opOrAssign(BitArray e2);
Support for operator |= for bit arrays.
BitArray opXorAssign(BitArray e2);
Support for operator ^= for bit arrays.
BitArray opSubAssign(BitArray e2);
Support for operator -= for bit arrays.
a -= b for BitArrays means the same thing as a &= ~b.
BitArray opCatAssign(bool b);
BitArray opCatAssign(BitArray b);
Support for operator ~= for bit arrays.
BitArray opCat(bool b);
BitArray opCat_r(bool b);
BitArray opCat(BitArray b);
Support for binary operator ~ for bit arrays.
分享到:
相关推荐
std.out for proe
dd-wrt.v24-9517_VINT_std.bin固件
IEEE Draft Std. P1857.9-D2:2021 Draft Std. for Standard for Imme
wegame 安装包
pm53C软件 pm53C软件 Setup-gen-PCIMC6-8.313.0-CHN-6B_std.exe
WeGameMiniLoader.std.5.11.28.1030.exe.cab
很多项目经常使用的两个头文件inttypes.h stdint.h,否则会报错。网上很多资料,但基本上不可用。这两个文件,我在自己的项目中运行良好。
ruamel.std.encryptedzip是一个经过修改的库,它向ruamel.std.zipfile添加了对加密zip存档的支持; 链接在下面。 这非常简单,它只是向API添加了一个额外的参数: def delete_from_zip_file ( self , pattern = ...
一、stdint.h是什么 stdint.h是C99标准引进的定义整形类型的C标准库头文件二、干什么stdint.h中定义了一些整数类型,规则如下
fatal error C1083: 无法打开包括文件:“stdint.h”: No such file or directory stdint.h是c99标准的头文件,vc不支持,所以肯定会提示“No such file or directory”的。 解决办法:下载文件之后将文件移动到...
INTERNATIONAL STANDARD:IEC 60488-2(E):2004 IEEE Std. 488.2(E):1992
包涵stdint.h inttypes.h这两个文件,很多的开源项目用到了这两个文件
可以用来解决VC不包含stdint.h头文件问题,网上下载的很多工程项目经常使用的两个头文件inttypes.h stdint.h,将头文件放到(以VS2008为例):C:\Program Files\Microsoft Visual Studio 9.0\VC\include(装在C盘时...
LoRa低功耗设计指南,涉及空中唤醒CAD等功能
Helvetica Neue LT Std.zip
注册瑞星积分账号,获得新人积分奖励,还可进入专属活动页,领取活动奖励。积分可参与抽奖或兑换相应优惠。
ProgDVB4[1].92.4Std.rar
由于代码中使用了头文件<stdint.h> 但是VS2005缺少头文件stdint.h,所以在"VS2005安装路径/VC/include"(例:C:\softwore\VS2005\VC\include)路径下添加stdint.h文件即可。
IEEE.Std.1149.6-2003 (jtag1149)
matlab最新license,亲测绝对可用,已经更新了原有license部分模块不能用的问题,另外可以无限期使用,不涉及到期问题,欢迎各位童鞋下载