Boost logo

Boost :

From: Peter.Bienstman_at_[hidden]
Date: 2001-07-17 10:21:05


This is another installment in my exploration of the boundaries of


  class_builder<Term> Term_(module, "Term");

  class_builder<Expression> Expression_(module, "Expression");
  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?



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