Boost logo

Boost :

From: Fernando Cacciola (fernando_cacciola_at_[hidden])
Date: 2003-02-24 15:59:29


"Philippe A. Bouchard" <philippeb_at_[hidden]> wrote in message
news:b3e08i$5pj$1_at_main.gmane.org...
> David Abrahams wrote:
> > "Philippe A. Bouchard" <philippeb_at_[hidden]> writes:
> >
> >> Yes, exactly. Sorry if I wasn't precise enough.
> >>
> >> The bool type will cancel type_with_alignment<> effects (at least on
> >> Intel compatible platforms); i.e. unique alignment of each
> >> optional<T> type.
> >
> > Sounds like you want
> >
> > type_with_alignment<T>::type storage;
> > new ((void*)&storage) T(x, y, z)
> >
> > Can you really do anything to make this cleaner? I guess:
> >
> > aligned_storage<T> storage;
> > new (storage.bytes) T(x, y, z);
> >
> > might be a help. What else are you gaining? And how do you destroy
> > the T? If not explicitly and you don't have a "constructed" flag,
> > you're going to have exception-safety problems.
>
> Everything seems already defined ;)
>
> Given the fact optional<>::m_storage is aligned like a bool...:
>
It is not aligned like a bool...

> - Maybe aligned_storage<> should always destruct its object. It would be
> the user's responsability to construct the object before its destruction,
> otherwise the result would be undefined.
>
Why would this be useful?

> - Maybe we could create 2 separate type lists if optional<> is used many
> times in the same object, gathering m_initialized types and m_storage in
> separate lists:
>
What for ?

--
Fernando Cacciola

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