Hi,
I've got several questions about the former version of boost::shared_ptr. Would someone please help me?
1. Mr Stroustrup said that there wasn't a need for auto_array, for "a better solution is to use a vector". So, should we use vector or scoped_array/shared_array?
2. In the document, four implementations are said to have been discussed: Direct detached, Indirect detached, Embedded detached and Placement detached. I've tried to describle them (Are I right? See the attached file), but I don't understand the Placement detached. Could someone please tell me what it's like?
3. In the file smart_ptr.hpp, we can see the private function shared_ptr::share.
void share(T* rpx, long* rpn) {
if (pn != rpn) {
++*rpn; // done before dispose() in case rpn transitively
// dependent on *this (bug reported by Ken Johnson)
dispose();
px = rpx;
pn = rpn;
}
} // share
I'm sorry that I don't understand that reason why ++*rpn should be done before dispose(). Would someone please give me an example? Or is it like this?
#include