在 boost::python 中公开 boost::scoped_ptr
我收到一个编译错误,指出 scoped_ptr
的复制构造函数是私有的,具有以下代码片段:
class a {};
struct s
{
boost::scoped_ptr<a> p;
};
BOOST_PYTHON_MODULE( module )
{
class_<s>( "s" );
}
不过,此示例适用于共享_ptr。如果有人知道答案,那就太好了。谢谢
I am getting a compile error, saying that the copy constructor of the scoped_ptr
is private with the following code snippet:
class a {};
struct s
{
boost::scoped_ptr<a> p;
};
BOOST_PYTHON_MODULE( module )
{
class_<s>( "s" );
}
This example works with a shared_ptr though. It would be nice, if anyone knows the answer. Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
boost::scoped_ptr
的语义禁止复制,而shared_ptr
则旨在复制。您收到的错误是编译器告诉您某些代码(宏扩展?)正在尝试复制scoped_ptr
但库不允许进行复制。The semantics of
boost::scoped_ptr
prohibit taking copies, whileshared_ptr
is intended to be copied. The error you are getting is the compiler telling you that some of the code (macro expansion?) is trying to copy thescoped_ptr
but that the library does not allow the copy to be made.