Simple question here: are you allowed to explicitly delete a boost::shared_ptr
yourself? Should you ever?
Clarifying, I don\'t mean delete the pointer held
If you want to simulate the count decrement, you can do it manually on the heap like so:
int main(void) {
std::shared_ptr* sp = new std::shared_ptr(std::make_shared(std::string("test")));
std::shared_ptr* sp2 = new std::shared_ptr(*sp);
delete sp;
std::cout << *(*sp2) << std::endl; // test
return 0;
}
Or on the stack using std::shared_ptr::reset()
like so:
int main(void) {
std::shared_ptr p = std::make_shared(std::string("test"));
std::shared_ptr p2 = p;
p.reset();
std::cout << *p2 << std::endl; // test
return 0;
}
But it's not that useful.