Boost logo

Boost :

From: David Abrahams (david.abrahams_at_[hidden])
Date: 2001-07-08 21:26:20


Mmm, yes. It looks like VC thinks you're trying to use partial ordering.
Your best bet at this point is to re-use the trick used by the rest of
boost::python. Note that this trick is not truly portable, but works with
many existing compilers.

BOOST_PYTHON_BEGIN_CONVERSION_NAMESPACE
template <class T>
struct old_shared_ptr_converters {

  friend PyObject* to_python(boostold::shared_ptr<T> p) {
    return

boost::python::python_extension_class_converters<T>::smart_ptr_to_python(p);
  }

  friend boostold::shared_ptr<T>& from_python(PyObject* p,
    boost::python::type<boostold::shared_ptr<T>&>)
    { return

boost::python::python_extension_class_converters<T>::smart_ptr_reference(p,
      boost::python::type<boostold::shared_ptr<T> >()); }

  friend const boostold::shared_ptr<T>& from_python(PyObject* p,
    boost::python::type<boostold::shared_ptr<T> >)
    { return
  boost::python::python_extension_class_converters<T>::smart_ptr_value(p,
  boost::python::type<boostold::shared_ptr<T> >()); }

  friend const boostold::shared_ptr<T>& from_python(PyObject* p,
    boost::python::type<const boostold::shared_ptr<T>&>)
    { return
     friend
boost::python::python_extension_class_converters<T>::smart_ptr_value(p,
    boost::python::type<boostold::shared_ptr<T> >()); }

};

BOOST_PYTHON_END_CONVERSION_NAMESPACE

And then, for each type T you're wrapping, get
BOOST_PYTHON_CONVERSION::old_shared_ptr_converters<T> instantiated, by
whatever your favorite means. One possibility would be to make your own
class_builder template that inherits from both the
boost::python::class_builder and your old_shared_ptr_converters.

Working around VC bugs is fun, innit? :(


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