Create a pcl::PointCloud::Ptr from a pcl::PointCloud

Yes, use the makeShared() method.


I know this is old and probably of no more use to OP, but other users might stumble upon it. I would suggest doing it as follows:

pcl::PointCloud<pcl::PointXYZRGB>::Ptr cloudPTR(new pcl::PointCloud<pcl::PointXYZRGB>);
*cloudPTR = createPointCloud(nodeList);

The reason Jonathon's answer is dangerous is that Pointcloud::Ptr is a typedef for a boost::shared_ptr which implies ownership of the object pointed to. In his answer, however, the object is actually a local variable meaning that it might go out of scope while there are still references to it and that shared_ptr will eventually call delete on it, which is undefined behavior.

Using make_shared() on the other hand deep copies the cloud. The program will work correctly, but if you didn't need the extra copy, it is far from optimal.