shared_ptr stores a pointer to a dynamically allocated object. It performs reference counting and will call delete on the original object when the last shared_ptr pointing to the object is destroyed (or reset).
shared_ptr was included in the C++11 standard, as std::shared_ptr. It is recommended to use the standard library version unless backwards compatibility is required.
px != 0 failed
If you get the runtime error:
Assertion px != 0 failed.
it usually means you tried to access the stuff the shared_ptr was pointing to before allocating it anything. This is the equivalent of trying to de-reference a raw pointer that is equal to null and getting a segmentation fault, except shared_ptr is smarter and checks this for you.
Posted: December 15th, 2016 at 8:14 pm
Last Updated on: June 11th, 2017 at 12:29 pm