Boost Users :
From: Michal Kandulski (Michal.Kandulski_at_[hidden])
Date: 2005-08-09 03:37:33
Douglas Gregor wrote:
> On Aug 5, 2005, at 2:07 PM, Michal Kandulski wrote:
>>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
> 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.
Thanks for the answer, but I've already checked both optional and variant.
OK. I can get a POD type suitable to store an object of X, but
my problem is: how to determine whether the object can be stored in
a given stack "allocated" buffer of given size.
My input data is:
- (aligned_storage<alignment_of<X>::value, sizeof(X)>::type)
And the question is again: can store an object of X in m_impl_buffer
and if I can - where?
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net