【发布时间】:2012-01-17 23:35:49
【问题描述】:
我有一个现有的变量,例如
int a = 3;
我现在如何创建boost::shared_ptr 到a?例如:
boost::shared_ptr< int > a_ptr = &a; // this doesn't work
【问题讨论】:
-
你为什么要这么做?
-
@curiousguy,我这样做的原因如下所述;我在堆栈上有一个变量,并且有一个需要共享点作为输入参数的函数。
-
我想知道为什么函数需要
shared_ptr! -
啊哈 - 我正在使用点云库 (pointclouds.org),整个 API 旨在使用共享指针。
标签: c++ boost shared-ptr smart-pointers