
On Fri, Oct 25, 2013 at 9:11 AM, Oliver Kowalke
2013/10/25 Andrey Semashev
intrusive_ptr is not trivial-copyable, precisely because it has to operate on the counter. Using memcpy for copying it is not correct.
For this reason it is
not compatible with atomic<>. You have to use raw pointers with atomic<>.
I don't agree because the standard told us:
1.) 'For any object of trivially copyable type T, whether or not the object holds a valid value of type T, the underlying bytes making up the object can be copied into an array of char or unsigned char. If the content of the array of char or unsigned char is copied back into the object, the object shall subsequently hold its original value.'
[...]
2.) 'For any trivially copyable type T, if two pointers to T point to distinct T objects obj1 and obj2, where neither obj1 nor obj2 is a base-class subobject, if the underlying bytes (1.7) making up obj1 are copied into obj2,41 obj2 shall subsequently hold the same value as obj1.'
Intrusive_ptr doesn't have tivial copy constructor (how could it have? it needs to update the counter), ergo is not trivially copyable and the above two point do not apply. -- gpd