Boost logo

Boost :

Subject: Re: [boost] Re : Using an element of a class A in a constructor of a class B (reflection with boost::python)
From: Jim Bosch (talljimbo_at_[hidden])
Date: 2012-03-10 22:37:08

On 03/10/2012 09:32 PM, christophe jean-joseph wrote:
> Thank you for your message, but it does not answer my question, I know how to reflect a C++ constructor under Python through boost and have absolutly no problem with that.
> My question is about reflecting Bctor(A& a, double& x) where Bctor is the constructor of class B and A another class.
> As I said, I can do that for any other function, except a constructor.
> I already read many website, including python and boost websites, before asking my question here.
> The link you provided, and that I already read before, only explain how to reflect a constructor.
> That would be of great help if anyone could give me some clue.

If the "double &" argument is intended to return a value, then I'm
afraid you're pretty much stuck, unless you're willing to put the value
in some kind of mutable proxy object (e.g. a one-element list). Python
floats are immutable, so they simply can't be used as output arguments.
  And since constructors can't return values, you can't just change the
signature. That's a Python limitation, not a Boost.Python one.

If you don't care about the value of the "double &" argument after the
call, you can just pretend that it's passed by value, i.e.:

namespace bp = boost::python;


By the way, you'll probably get more attention on Boost.Python questions
on the cplusplus-sig_at_[hidden] mailing list.


Boost list run by bdawes at, gregod at, cpdaniel at, john at