The problem here isn't a mismatch between double and float, it's that
Python's float object is immutable, and hence there's no way to
translate it into a C++ lvalue.  You simply can't wrap a C++ function
with a "double &" (or "int &" or "string &") argument to Python with
the same signature, regardless of whether you're using Boost.Python or
something else, because Python won't allow the argument you pass to be
changed.

You have two options:

 - Add an extra struct (similar to your NativeDouble idea) that is a
wrapped class that only contains a double.  But you'll need explicit
get/set methods, not just a public data member, though you can add a
Python property to make the get/set look like a data member.

 - Transform the function signature, by wrapping a new function that
takes a non-reference double and returns the new one, delegating it's
work to the original function.

Jim
_______________________________________________
Cplusplus-sig mailing list
Cplusplus-sig@python.org
https://mail.python.org/mailman/listinfo/cplusplus-sig

Reply via email to