Boost logo

Boost :

From: Peter.Bienstman_at_[hidden]
Date: 2001-07-18 02:42:30


> > 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?
>
> I am assuming that Term can be implicitly converted to (but is not
derived
> from) Expression here. I think that in this case, you can just add
the
> following:
>
> User_.def(constructor<const Term&>);

Note that there is no User(Term) constructor in my original C++ code,
only a contructor Expression(Term) (and a conversion operator Term-
>Expression, but this does not seem to make a difference).

Anyway, adding

   User_.def(constructor<const Term&>);

, gives a compile-time error (with User replaced by Slab) :

/home/pbienst/boost_1_22_0/boost/python/detail/extension_class.hpp:
In
   constructor
   `boost::python::detail::held_instance<Held>::held_instance
(PyObject*, A1)
   [with A1 = boost::python::detail::reference_parameter<const
Term&>, Held =
   Slab]':
/home/pbienst/boost_1_22_0/boost/python/detail/init_function.hpp:743:
  instantiated from `boost::python::detail::instance_holder_base*
boost::python::detail::init1<T, A1>::create_holder
(boost::python::detail::extension_instance*, PyObject*, PyObject*)
const [with T = boost::python::detail::instance_value_holder<Slab,
boost::python::detail::held_instance<Slab> >, A1 = const Term&]'
/home/pbienst/gnu/include/g++-v3/bits/stl_construct.h:79:
instantiated from here
/home/pbienst/boost_1_22_0/boost/python/detail/extension_class.hpp:687
: no
   matching function for call to
   `Slab::Slab(boost::python::detail::reference_parameter<const
Term&>&)'
primitives/slab/slab.h:208: candidates are: Slab::Slab(const Slab&)
primitives/slab/slab.h:211: Slab::Slab(const
Expression&)


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk