|
Boost : |
From: Joel de Guzman (djowel_at_[hidden])
Date: 2003-04-19 20:13:44
Giovanni Bajo wrote:
> (sorry for the previous empty post)
>
> Hello,
>
> Since the aligned storage "wastes" bytes to align the type, is it
> possible to place the boolean "m_initialized" within the alignment
> padding? Basically, you could define dummy.data[] one byte bigger,
> and use it for m_initialized. This way, you could save space in many
> situations.
>
> I would propose a patch but I don't understand all the details of the
> alignment issues. Besides, I'm not sure it would be legal to do so.
Heh, I was just thinking about this the other day...
Right off the bat, we can detect at compile-time if the padding
is non-zero and stuff m_initialized in the padding if it is not.
I think this can be done by putting the m_initialized handling
in the aligned_storage template. There will be a specialization
for the case where the padding is non-zero and the flag is placed
in the padding and another specialization for the case where padding
is zero and the flag is a data member. Generic accessor member functions
can be provided: bool is_initialized() const, void is_initialized(bool f);
-- Joel de Guzman joel at boost-consulting.com http://www.boost-consulting.com http://spirit.sf.net
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk