开发者

Boost.Python returning by internal reference

开发者 https://www.devze.com 2023-03-04 06:28 出处:网络
Given two classes: 开发者_如何学Pythonclass B { // ... }; class A { public: B& b() { return *b_; }

Given two classes:

开发者_如何学Pythonclass B {
  // ...
};

class A {
 public:
  B& b() { return *b_; }
 private:
  B* b_;
};

In the Boost.Python module, I have

bp::class_<B, boost::noncopyable>(...)...;

which works fine. I also have

bp::class_<A, boost::noncopyable>(...)
  .def("b", &A::b,
       bp::return_internal_reference<>()
      )

but it doesn't compile. It says:

/opt/local/include/boost/python/detail/caller.hpp:102:109: error: 'struct boost::python::detail::reference_existing_object_requires_a_pointer_or_reference_return_type<B>' has no member named 'get_pytype'

But, it should have a pytype, right?

0

精彩评论

暂无评论...
验证码 换一张
取 消