Exposing a pointer in Boost.Python

前端 未结 1 1636
囚心锁ツ
囚心锁ツ 2021-01-02 04:29

I have this very simple C++ class:

class Tree {
    public:
        Node *head;
};
BOOST_PYTHON_MODULE(myModule)
{

   class_(\"Tree\")
        .         


        
相关标签:
1条回答
  • 2021-01-02 04:52

    Of course, I find the answer ten minutes after asking the question...here's how it's done:

    class_<Tree>("Tree")
        .add_property("head",
         make_getter(&Tree::head, return_value_policy<reference_existing_object>()),
         make_setter(&Tree::head, return_value_policy<reference_existing_object>()))
    ;
    
    0 讨论(0)
提交回复
热议问题