
4 Jan
2010
4 Jan
'10
7:13 p.m.
Am Saturday 02 January 2010 23:34:51 schrieb vicente.botet:
Derived* p = reinterpret_cast<Derived*>( new char[sizeof(Derived)]); std::memcpy(p, static_cast<Derived const*>(this), sizeof(Derived)); return p; }
quick question about this, is it legal to do the following? T *t=reinterpret_cast<T *>(new char[sizeof(T)]); new (&t) T; delete T; Boost.Serialization must use that, as it passes unconstructed memory to load_construct_data but lets the user "delete" the object, so I figure it must be ok. am I right? my platform (with valgrind) doesn't have a problem with it, but is it defined to be ok or portable among all known platforms?