Why are std.bitmanip.bitfields so big ?

wjoe invalid at example.com
Tue Jul 28 13:47:09 UTC 2020


On Tuesday, 28 July 2020 at 13:00:12 UTC, Steven Schveighoffer 
wrote:
> 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

My reasoning was that a unittest is essentially a function and 
it's incredibly convenient for such things but I hadn't really 
checked prior to MoonlightSentinel's reply.

Thanks again :)


More information about the Digitalmars-d-learn mailing list