如果我有类似以下课程的内容
class Foo
{
private:
int _bar;
public:
Foo& operator=( const Foo& other )
{
_bar = other._bar;
return *this;
}
}
有没有一种简单的方法可以使用 boost::python 将该功能导出到 python?该文档没有列出并且很好很容易
.def( self = self )
我不是 python 专家,所以说实话我什至不知道这是否有必要。但我想在我的 python 脚本中使用这个功能,所以我发布这个问题只是为了确保。
编辑:
这是我做 .def( self = self ) 时的编译器错误
.\src\Python.cpp(12) : error C2780: 'boost::python::class_<W> &boost::python::class_<W>::def(const char *,Fn,const A1 &,const A2 &,const A3 &)' : expects 5 arguments - 1 provided
with
[
W=Foo
]
depends\common\include\boost/python/class.hpp(265) : see declaration of 'boost::python::class_<W>::def'
with
[
W=Foo
]
.\src\Python.cpp(12) : error C2780: 'boost::python::class_<W> &boost::python::class_<W>::def(const char *,Fn,const A1 &,const A2 &)' : expects 4 arguments - 1 provided
with
[
W=Foo
]
depends\common\include\boost/python/class.hpp(249) : see declaration of 'boost::python::class_<W>::def'
with
[
W=Foo
]
.\src\Python.cpp(12) : error C2780: 'boost::python::class_<W> &boost::python::class_<W>::def(const char *,A1,const A2 &)' : expects 3 arguments - 1 provided
with
[
W=Foo
]
depends\common\include\boost/python/class.hpp(242) : see declaration of 'boost::python::class_<W>::def'
with
[
W=Foo
]
.\src\Python.cpp(12) : error C2780: 'boost::python::class_<W> &boost::python::class_<W>::def(const char *,F)' : expects 2 arguments - 1 provided
with
[
W=Foo
]
depends\common\include\boost/python/class.hpp(233) : see declaration of 'boost::python::class_<W>::def'
with
[
W=Foo
]
.\src\Python.cpp(12) : error C2784: 'boost::python::class_<W> &boost::python::class_<W>::def(const boost::python::def_visitor<Derived> &)' : could not deduce template argument for 'const boost::python::def_visitor<Derived> &' from 'boost::python::self_ns::self_t'
with
[
W=Foo
]
depends\common\include\boost/python/class.hpp(223) : see declaration of 'boost::python::class_<W>::def'
with
[
W=Foo
]