[C++-sig] String param from py to c++ by reference?

Håkon Groven hgroven at emgs.com
Fri Aug 3 12:54:58 CEST 2007


I have a c++ function that is defined like this:
bool set_version(std::string &version); //pass by reference

The wrapper def:
.def("set_version", &survey_result::set_version)

Python code:
b = result.set_version('jalla')

This does not work, and I get the following error:

Caught Boost.Python.ArgumentError: Python argument types in
   survey_result.set_version(survey_result, str)
did not match C++ signature:
   set_version(survey_result {lvalue}, std::string {lvalue})

This works fine if I change the c++ code:
bool set_version(std::string version); //pass by value

Is it possible to make this work by reference instead of by value?

Haakon




More information about the Cplusplus-sig mailing list