From f2e34d4836eab58dfd123b1aba294f5ed1d799fe Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Mon, 30 Jul 2001 13:31:23 +0000 Subject: [PATCH] MSVC doesn't like boost::dereferencable unless T has a default constructor, so operator-> must be defined by hand [SVN r10720] --- include/boost/python/detail/cast.hpp | 7 ++++++- include/boost/python/reference.hpp | 9 ++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/include/boost/python/detail/cast.hpp b/include/boost/python/detail/cast.hpp index a6f2f046..e047c0b3 100644 --- a/include/boost/python/detail/cast.hpp +++ b/include/boost/python/detail/cast.hpp @@ -51,7 +51,7 @@ inline PyObject* as_object(PyTypeObject* p) { return reinterpret_cast // If I didn't have to support stupid MSVC6 we could just use a simple template function: // template T* downcast(PyObject*). template -struct downcast : boost::dereferenceable, T*> +struct downcast { downcast(PyObject* p) : m_p(detail::downcast_traits::cast(detail::as_base_object((T*)0, p))) @@ -70,6 +70,11 @@ struct downcast : boost::dereferenceable, 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: diff --git a/include/boost/python/reference.hpp b/include/boost/python/reference.hpp index c633b9d7..a1585099 100644 --- a/include/boost/python/reference.hpp +++ b/include/boost/python/reference.hpp @@ -20,7 +20,7 @@ BOOST_PYTHON_BEGIN_CONVERSION_NAMESPACE -template +template struct py_ptr_conversions : Base { inline friend T from_python(PyObject* x, boost::python::type) @@ -42,8 +42,7 @@ BOOST_PYTHON_IMPORT_CONVERSION(py_ptr_conversions); template class reference - : public py_ptr_conversions, T, - boost::dereferenceable, T*> > // supplies op-> + : public py_ptr_conversions, 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()