2
0
mirror of https://github.com/boostorg/python.git synced 2026-01-20 16:52:15 +00:00

MSVC doesn't like boost::dereferencable<T> unless T has a default constructor,

so operator-> must be defined by hand


[SVN r10720]
This commit is contained in:
Dave Abrahams
2001-07-30 13:31:23 +00:00
parent 3c6a8d718f
commit f2e34d4836
2 changed files with 12 additions and 4 deletions

View File

@@ -51,7 +51,7 @@ inline PyObject* as_object(PyTypeObject* p) { return reinterpret_cast<PyObject*>
// If I didn't have to support stupid MSVC6 we could just use a simple template function:
// template <class T> T* downcast(PyObject*).
template <class T>
struct downcast : boost::dereferenceable<downcast<T>, T*>
struct downcast
{
downcast(PyObject* p)
: m_p(detail::downcast_traits<T>::cast(detail::as_base_object((T*)0, p)))
@@ -70,6 +70,11 @@ struct downcast : boost::dereferenceable<downcast<T>, T*>
{}
operator T*() const { return m_p; }
// MSVC doesn't like boost::dereferencable unless T has a default
// constructor, so operator-> must be defined by hand :(
T* operator->() const { return &**this; }
T* get() const { return m_p; }
T& operator*() const { return *m_p; }
private:

View File

@@ -20,7 +20,7 @@
BOOST_PYTHON_BEGIN_CONVERSION_NAMESPACE
template <class T, class Value, class Base>
template <class T, class Value, class Base = boost::detail::empty_base>
struct py_ptr_conversions : Base
{
inline friend T from_python(PyObject* x, boost::python::type<const T&>)
@@ -42,8 +42,7 @@ BOOST_PYTHON_IMPORT_CONVERSION(py_ptr_conversions);
template <class T>
class reference
: public py_ptr_conversions<reference<T>, T,
boost::dereferenceable<reference<T>, T*> > // supplies op->
: public py_ptr_conversions<reference<T>, T>
{
public:
typedef T value_type;
@@ -117,6 +116,10 @@ public:
T& operator*() const { return *m_p; }
// MSVC doesn't like boost::dereferencable unless T has a default
// constructor, so operator-> must be defined by hand :(
T* operator->() const { return &**this; }
T* get() const { return m_p; }
T* release()