Boost.Python call by reference : TypeError: No to_python (by-value) converter found for C++ type: -


I am trying to expose my Pyro to Python using C + + classes Boost. Here's a simple version of what I'm trying to do:

By promoting a class A to me: noncopyable and with a second class B method, which in terms of A takes away. Category A: Promotion: Non-CoCAPPable {/*...*/}; Class B {Public: Virtual Zero do_something (A and A) {/*...*/}};

I am showing the classes as follows:

  / * Cover for B, then B can be extended into Python / struct BWP: Public B, Cover & lt; B & gt; {Cancel (A and A) {If (override do_something = this-> get_override ("do_something")) {do_something (A); Return; } And {b :: what_group (a); }} Zero default_ do_something (A and A) {it-> B :: What_Group (A); }}; BOOST_PYTHON_MODULE (some modules) {class_ & lt; A, Promotion: Non-Cocaable & gt; ("a"); Class_ & lt; BWrap, Promotion: Non-Coccalable & gt; ("B"). F ("dot_group", & amp; b :: dots_groups, and bwp :: default_d_sms); }   

I expand B in Python like this:

test.py:

  import some module class BDerived (SomeModule.B): Def do_something (auto, A): pass   

and thus call Extended B:

  try {py :: Object main = py :: import ("__ main__"); \ Py :: Object Global (main.tv ("___director")); \ Py :: object result = py :: exec_file ("test.py", global, global); \ Py :: object pluginClass = global ["BDerived"]; \ Py :: object plugin_base = pluginClass (); \ B & amp; Plugin = P :: Extract & lt; B & gt; (Plugin_base) BOOST_EXTRACT_WORKAROUND; AA; B.do_something (a); } Hold (py :: error_already_set) {PyErr_Print (); }   

Although it results in an error message:

  Type torre: No to_python (by-value) converter for type C ++ was found: A   

If the A is not derived from boost :: noncopyable , the code runs without error, but the logic < A> code_something (A & A) function copied during the call, even if it has been passed from context.

Any suggestions how to solve the problem?

Thanks, but there is an option to remove noncopyable requirement on A because there is only one reason. .

change bO_assembly (a); to b.do_something (boost: ref (a)); .

See in the Boost Manual.

Comments