C++ boost::python::返回值策略<;bp::引用\现有\对象>;()weakref是python中的吗?
我过去使用过C++ boost::python::返回值策略<;bp::引用\现有\对象>;()weakref是python中的吗?,c++,python,boost,C++,Python,Boost,我过去使用过boost::python,但这个问题一直困扰着我。这是我遇到问题的部分课程: class Entity { public: Entity(); ~Entity(); //Call to check our collider against all entities that have "tag" Collider* Collide(const std::string &tag); }; 下面是boost::python代码: bp::cl
boost::python
,但这个问题一直困扰着我。这是我遇到问题的部分课程:
class Entity
{
public:
Entity();
~Entity();
//Call to check our collider against all entities that have "tag"
Collider* Collide(const std::string &tag);
};
下面是boost::python
代码:
bp::class_< Entity_wrapper >( "Entity", bp::init< >() )
.def(
"Collide"
, (::Monocle::Collider * ( ::Monocle::Entity::* )( ::std::string const & ) )( &::Monocle::Entity::Collide )
, ( bp::arg("tag") ),
bp::return_value_policy<bp::reference_existing_object>() )
碰撞器
是类型
的弱点,而不是碰撞器
。我的其他返回指针的函数似乎很好。这只是我使用的通话策略吗?Collide所做的是调用Collion类的静态函数(“Collide”),该函数在成功时返回Collider*,否则返回NULL
任何帮助都将不胜感激!如果您需要更多信息,请告诉我 boost::python代码没有正确发布,这里又是:bp::class
CircleCollider
和RectangleCollider
的。
collider = entity.Collision("Paddle")