|
Boost : |
From: Peter.Bienstman_at_[hidden]
Date: 2001-07-17 10:21:05
Hi,
This is another installment in my exploration of the boundaries of
boost::python.
Consider
class_builder<Term> Term_(module, "Term");
Term_.def(constructor<>());
class_builder<Expression> Expression_(module, "Expression");
Expression_.def(constructor<>());
Expression_.def(constructor<const Term&>());
class_builder<User> User_(module, "User");
User_.def(constructor<const Expression&>();
Using the original C++ code, I could write
Term t=Term();
User u=User(t);
, because C++ is smart enough to figure out how to construct an
Expression from a Term.
Now, trying the same in Python, we get
>>>t = Term()
>>>u = User(t)
TypeError: extension class 'Term' is not convertible
into 'Expression'.
Short of modifying the original C++ code to add a User::User(const
Term&) constructor, is there anything I can do to get the Boost
typesystem to apply Expression::Expression(const Term&) for me?
Thanks,
Peter
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk