You are not logged in.
Hi, I'm trying to wrap a class member function which have a non-const reference argument:
bool GetData(const char *name, int &ref);
This method searches a (name, value) map and place the value in the referenced variable. The python binding i wrote looks like:
def("GetData", &DataService::GetData)
but when I invoke the method in the python shell I get this error:
>>> ds.GetData("dummy", c)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
Boost.Python.ArgumentError: Python argument types in
DataService.SetData(DataService, str, int)
did not match C++ signature:
GetData(DataService {lvalue}, char const*, int {lvalue})
I searched the web and it seems that non-const references as function arguments are somewhat problematic for Boost.Python. The funny thing is that in the official Boost.Python tutorail, in the Call Policies section, there is a very detailed example which makes extensive use of non-const references:
http://www.boost.org/doc/libs/1_50_0/li … l_policies
which does not work (at least, not for me).
I'm a bit puzzled, so can anyone please tell me if it is possible to wrap non-const reference arguments and how? Thanks.
Offline
OK, it seems that if instead of an int& I use a Type& (where Type is a class that has been properly wrapped using class_<>) everything works. But I would need to use a reference to a primitive type as the argument...
Offline