本文整理汇总了C++中Bits::test方法的典型用法代码示例。如果您正苦于以下问题:C++ Bits::test方法的具体用法?C++ Bits::test怎么用?C++ Bits::test使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Bits
的用法示例。
在下文中一共展示了Bits::test方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: assert
dt_t *ArrayInitializer::toDtBit()
{
#if DMDV1
unsigned size;
unsigned length;
unsigned tadim;
dt_t *d;
dt_t **pdtend;
Type *tb = type->toBasetype();
//printf("ArrayInitializer::toDtBit('%s')\n", toChars());
Bits databits;
Bits initbits;
if (tb->ty == Tsarray)
{
/* The 'dim' for ArrayInitializer is only the maximum dimension
* seen in the initializer, not the type. So, for static arrays,
* use instead the dimension of the type in order
* to get the whole thing.
*/
dinteger_t value = ((TypeSArray*)tb)->dim->toInteger();
tadim = value;
assert(tadim == value); // truncation overflow should already be checked
databits.resize(tadim);
initbits.resize(tadim);
}
else
{
databits.resize(dim);
initbits.resize(dim);
}
/* The default initializer may be something other than zero.
*/
if (tb->next->defaultInit()->toInteger())
databits.set();
size = sizeof(databits.data[0]);
length = 0;
for (size_t i = 0; i < index.dim; i++)
{ Expression *idx;
Initializer *val;
Expression *eval;
idx = (Expression *)index.data[i];
if (idx)
{ dinteger_t value;
value = idx->toInteger();
length = value;
if (length != value)
{ error(loc, "index overflow %llu", value);
length = 0;
}
}
assert(length < dim);
val = (Initializer *)value.data[i];
eval = val->toExpression();
if (initbits.test(length))
error(loc, "duplicate initializations for index %d", length);
initbits.set(length);
if (eval->toInteger()) // any non-zero value is boolean 'true'
databits.set(length);
else
databits.clear(length); // boolean 'false'
length++;
}
d = NULL;
#ifdef IN_GCC
pdtend = dtnbits(&d, databits.allocdim * size, (char *)databits.data, sizeof(databits.data[0]));
#else
pdtend = dtnbytes(&d, databits.allocdim * size, (char *)databits.data);
#endif
switch (tb->ty)
{
case Tsarray:
{
if (dim > tadim)
{
error(loc, "too many initializers, %d, for array[%d]", dim, tadim);
}
else
{
tadim = (tadim + 31) / 32;
if (databits.allocdim < tadim)
pdtend = dtnzeros(pdtend, size * (tadim - databits.allocdim)); // pad out end of array
}
break;
}
case Tpointer:
case Tarray:
// Create symbol, and then refer to it
Symbol *s;
s = static_sym();
s->Sdt = d;
//.........这里部分代码省略.........