Boost logo

Boost :

From: Larry Evans (cppljevans_at_[hidden])
Date: 2005-08-10 11:10:55


On 08/10/2005 09:27 AM, christopher diggins wrote:
[snip]
> Anyway it turns out we can guarantee alignment by simply using a char
> buffer. According to 3.9/2 the following automatically has no alignment
> problems:
>
> template<int buffer_size>
> struct any {
> char buffer[buffer_size];
> ...
> template<typename T>
> any(const T& x) {
> if (boost::is_pod<T>::value && (sizeof(T) <= buffer_size)) {
> memcpy(buffer, &T, N);
Wouldn't this fail to update the refcount if T was shared_ptr or
weak_ptr?
> }
> else {
> // new and stuff
> }
> }
> }


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