c++ - 在 boost::python 中公开 boost::scoped_ptr

标签 c++ boost smart-pointers boost-python

我收到一个编译错误,说 scoped_ptr 的复制构造函数是私有(private)的,代码片段如下:

class a {};

struct s
{
  boost::scoped_ptr<a> p;
};

BOOST_PYTHON_MODULE( module )
{
  class_<s>( "s" );
}

虽然这个例子适用于 shared_ptr。如果有人知道答案,那就太好了。谢谢

最佳答案

boost::scoped_ptr 的语义禁止复制,而 shared_ptr 旨在被复制。您得到的错误是编译器告诉您某些代码(宏扩展?)正在尝试复制 scoped_ptr 但库不允许进行复制。

关于c++ - 在 boost::python 中公开 boost::scoped_ptr,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2577437/

相关文章:

c# - Windows shell 扩展 : context menu when more than 16 files are selected

c++ - 使用 boost asio 和 SSL 时消息过大

c++ - 集合的结构之间的比较

c++ - 使用智能指针或引用包装器定义自定义 map

c++ - shared_ptr 不能为空?

c++ - 轻松编写保持状态的模拟

c++ - 如何将 QPen 与 QpainterPath 一起使用?

c++ - 重新实现 acceptNavigationRequest()

c++ - 如何解决boost多线程简单程序的编译错误

c++ - 将 CString 与 boost 字符串算法一起使用 - 减少到一个 typedef?