开发者

Boost.Python returning by internal reference

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜