在boost :: python中公开boost :: scoped_ptr

Rup*_*nes 4 c++ boost smart-pointers boost-python

我收到一个编译错误,说该scoped_ptr私有的复制构造函数与以下代码片段:

class a {};

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

BOOST_PYTHON_MODULE( module )
{
  class_<s>( "s" );
}
Run Code Online (Sandbox Code Playgroud)

此示例适用于shared_ptr.如果有人知道答案那就太好了.谢谢

Dav*_*eas 6

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