
10 Aug
2005
10 Aug
'05
4:10 p.m.
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 } } }