Category "shared-ptr"

Why do std::shared_ptr<void> work

I found some code using std::shared_ptr to perform arbitrary cleanup at shutdown. At first I thought this code could not possibly work, but then I tried the fol

stoi out ouf range exception when reusing unique ptr

I'm trying to transmitt a draco encoded point cloud via socket.io. In the first iteration everything is fine but in every following iteration abort() is being c

Inheritance and std::shared_ptr in Cython

Suppose I have the following simple example of C++ inheritance in file.h: class Base {}; class Derived : public Base {}; Then, the following code compiles; tha

How to avoid the need to specify deleter for std::shared_ptr every time it's constructed or reset?

std::unique_ptr has 2 template parameters, the second of which is the deleter to be used. Thanks to this fact, one can easily alias a unique_ptr to a type, whic

shared_from_this causing bad_weak_ptr

I am trying to keep a list of connected clients in asio. I have adapted the chat server example from the docs (http://www.boost.org/doc/libs/1_57_0/doc/html/boo

pcl::PointCloud<pcl::PointXYZ> to pcl::PointCloud<pcl::PointXYZ>::Ptr (Covert poincloud to ptr)

I am using PCL 1.3. Is there any function to convert pointcloud to pointcloud::ptr. I am new at PCL libraries. I have a ROS node subscribing to sensor_msgs/Poin

Why can't a weak_ptr be constructed from a unique_ptr?

If I understand correctly, a weak_ptr doesn't increment the reference count of the managed object, therefore it doesn't represent ownership. It simply lets you

When is std::weak_ptr useful?

I started studying smart pointers of C++11 and I don't see any useful use of std::weak_ptr. Can someone tell me when std::weak_ptr is useful/necessary?

How do I call ::std::make_shared on a class with only protected or private constructors?

I have this code that doesn't work, but I think the intent is clear: testmakeshared.cpp #include <memory> class A { public: static ::std::shared_pt