Could someone explain what boost shared_ptr manual means by this:
If you are using unique() to implement copy on write, do not rely on a specific value when the stored pointer is zero.
Thanks.
Copy-on-write is a storage scheme where copies of an object with duplicate values are represented by a single object. Only when you try to change one is it copied to a new, unique object.
Boost supports this by telling you whether a given shared_ptr is supporting more than one reference. If it is, then writing to the object will require making a copy.
The manual is saying that if you have NULL pointers in such a scheme, they might report being either unique or not. Really, Boost is being generous by even allowing such an operation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With