
On Aug 5, 2005, at 2:07 PM, Michal Kandulski wrote:
Hi!
I'd like to implement a pimpl, pointing to a stack "allocated" buffer by means of palcement new/destroy.
There would be no problem but there are alignment issues.
What really I need is: - a way to check by te means of Boost wheater that an object of class X can be placed (with placement new) in a buffer of given adress and size: - a way of getting a pointer to X (within the buffer) where the object could be paced
boost::optional<T> does this, as does the more-complicated boost::variant. You'll want to use the type traits alignment_of (to find the alignment of a type) and type_with_alignment (to find a POD type with a given alignment). If you dig around Boost for aligned_storage you'll see the technique we've used. Doug