Boost logo

Boost :

Subject: Re: [boost] [optional] memory use for optional refs and ptrs
From: Sebastian Redl (sebastian.redl_at_[hidden])
Date: 2010-10-06 08:25:14


On 06.10.2010 14:09, Rutger ter Borg wrote:
>
> On 2010-10-06 13:11, Stewart, Robert wrote:
>
>> (I haven't looked, but I do hope that the bool follows the optional
>> value to reduce padding overhead.)
>
> It doesn't, the boolean is followed by the optional value (see
> boost/optional/optional.hpp lines 447-448).
I really don't think it makes a difference. Unless you're using
compiler-specific packing instructions, the size of a struct will always
be a multiple of the largest alignment of any of its subobjects. In
other words, no matter where you place the bool, it will take as much
space as the alignment of the value.

Sebastian


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk