Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/349.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ boost::python::返回值策略<;bp::引用\现有\对象>;()weakref是python中的吗?_C++_Python_Boost - Fatal编程技术网

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(“Entity”,bp::init<>()).def(“Collide”,(::Monocle::Collider*(::Monocle::Entity:::*)(::std::string const&)(&::Monocle::Entity::Collide),(bp::arg(“tag”)、bp::return\u value\u policy())您是否已经包装了碰撞器类?(根据代码片段,看起来您使用的是Py++,但您永远不知道……),如果是github上zaphire的单镜头引擎,可能还有
CircleCollider
RectangleCollider
的。
collider = entity.Collision("Paddle")