strtr:
> static if( S.sizeof == members.sizeof )
> S s = void;
> else
> S s;
You can use something like this :-)
import std.stdio: writeln;
int unusedBytesStruct(S)() if (is(S == struct)) {
int totUsed;
foreach (field; S.init.tupleof)
totUsed += field.sizeof;
return cast(in
The situation is ugly, see the post in the main newsgroup:
http://www.digitalmars.com/webnews/newsgroups.php?art_group=digitalmars.D&article_id=107153
Bye,
bearophile
strtr:
>Might this be worth an explicit mention on digitalmars?<
Currently the documentation has some semantic holes that must be filled :-)
> Suppose I'd still would like to use void optimizations, how do you clear the
> holes manually?
If you need to fill the holes manually, then probably it
BCS Wrote:
> IIRC zero filling a block is likely cheaper that zero filling holes in it.
> I'd avoid "=void" unless you know you will be copying structs into the space
> (that will copy the holes as well).
And unless you will never compare the struct, as the garbage bits will also be
compared.
I
Hello Strtr,
Suppose I'd still would like to use void optimizations, how do you
clear the holes manually?
IIRC zero filling a block is likely cheaper that zero filling holes in it.
I'd avoid "=void" unless you know you will be copying structs into the space
(that will copy the holes as well
bearophile Wrote:
> strtr:
>
> > I suspect this isn't the case for void initialization; if my struct has
> > some alignment hole I better not void initialize it if ever I want to
> > compare it with something.
> > Is this correct?
>
> That has to be correct.
Might this be worth an explicit men
Hello Strtr,
BCS Wrote:
Hello Strtr,
Would you ever have an alignment hole if all the struct contains are
basic types(excluding bool)?
real, char[n], byte[n] and short[m] (for n%4 != 0 and m%2 != 0) might
be an issue.
Sounds logical, thanks!
I don't actually *know* those will be a pro
BCS Wrote:
> Hello Strtr,
>
> > Would you ever have an alignment hole if all the struct contains are
> > basic types(excluding bool)?
>
> real, char[n], byte[n] and short[m] (for n%4 != 0 and m%2 != 0) might be
> an issue.
>
Sounds logical, thanks!
Hello Strtr,
Would you ever have an alignment hole if all the struct contains are
basic types(excluding bool)?
real, char[n], byte[n] and short[m] (for n%4 != 0 and m%2 != 0) might be
an issue.
--
... <
strtr:
> I suspect this isn't the case for void initialization; if my struct has some
> alignment hole I better not void initialize it if ever I want to compare it
> with somthing.
> Is this correct?
That has to be correct.
> Would you ever have an alignment hole if all the struct contains ar
This is probably going a bit above my head, but
"the existence of alignment holes in the objects is accounted for, usually by
setting them all to 0 upon initialization"
I suspect this isn't the case for void initialization; if my struct has some
alignment hole I better not void initialize it if
11 matches
Mail list logo