Boost Libraries

Article by:
Date Published:
Last Modified:


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.

Assertion 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.


Geoffrey Hunter

Dude making stuff.

Creative Commons License
This work is licensed under a Creative Commons Attribution 4.0 International License .

Related Content

No related content found.


    comments powered by Disqus