Why are std.bitmanip.bitfields so big ?

Steven Schveighoffer schveiguy at gmail.com
Tue Jul 28 13:00:12 UTC 2020


On 7/28/20 5:46 AM, MoonlightSentinel wrote:
> On Tuesday, 28 July 2020 at 09:28:27 UTC, wjoe wrote:
>> It was run on the doc page. I suppose the examples are wrapped in a 
>> unittest block?
> 
> Indeed, see 
> https://github.com/dlang/phobos/blob/cd2ba0d2c378a893ec0eaefc57b87d0770a1990c/std/bitmanip.d#L293-L314 
> 

It doesn't necessarily need to be in a unittest block (AFAIK, the 
example executer isn't actually running the unittests of phobos), but it 
does need to be inside a function, because you have executable code 
there. Either way, yes, it's run inside a function, so you need to apply 
static to the struct to avoid the frame pointer. I tested that, and it 
prints 1 instead of 16.

-Steve


More information about the Digitalmars-d-learn mailing list