1515#include < boost/python/copy_const_reference.hpp>
1616#include < boost/python/return_value_policy.hpp>
1717#include < boost/python/converter/class.hpp>
18- #include < boost/python/reference_from_python .hpp>
18+ #include < boost/python/lvalue_from_python .hpp>
1919#include < boost/python/to_python_converter.hpp>
2020#include < boost/python/value_from_python.hpp>
2121#include < boost/python/errors.hpp>
@@ -141,6 +141,26 @@ int f(simple const& s)
141141 return strlen (s.s );
142142}
143143
144+ int f_mutable_ref (simple& s)
145+ {
146+ return strlen (s.s );
147+ }
148+
149+ int f_mutable_ptr (simple* s)
150+ {
151+ return strlen (s->s );
152+ }
153+
154+ int f_const_ptr (simple const * s)
155+ {
156+ return strlen (s->s );
157+ }
158+
159+ int f2 (SimpleObject const & s)
160+ {
161+ return strlen (s.x .s );
162+ }
163+
144164// A trivial passthru function for simple objects
145165simple const & g (simple const & x)
146166{
@@ -188,7 +208,7 @@ BOOST_PYTHON_MODULE_INIT(m1)
188208 using boost::python::module ;
189209 using boost::python::class_;
190210 using boost::python::converter::from_python_converter;
191- using boost::python::reference_from_python ;
211+ using boost::python::lvalue_from_python ;
192212 using boost::python::value_from_python;
193213 using boost::python::type_from_python;
194214 using boost::python::get_member;
@@ -205,14 +225,21 @@ BOOST_PYTHON_MODULE_INIT(m1)
205225 static from_python_converter<int &> c3 (
206226 &(boost::python::type_from_python<&NoddyType>::convertible), noddy_to_int_ref);
207227
208- static boost::python::reference_from_python <
228+ static boost::python::lvalue_from_python <
209229 &SimpleType
210230 , simple
211231 , SimpleObject
232+ #if !defined(BOOST_MSVC) || BOOST_MSVC > 1300
233+ , boost::python::get_member<SimpleObject, simple, &SimpleObject::x>
234+ #else
212235 , extract_simple_object
236+ #endif
213237 >
214238 unwrap_simple;
215239
240+ static boost::python::lvalue_from_python<&SimpleType, SimpleObject>
241+ unwrap_simple2;
242+
216243 module m1 (" m1" );
217244
218245 typedef boost::python::objects::pointer_holder_generator<
@@ -229,9 +256,14 @@ BOOST_PYTHON_MODULE_INIT(m1)
229256 .def (" new_noddy" , new_noddy)
230257 .def (" new_simple" , new_simple)
231258
232- // Expose f()
259+ // Expose f() in all its variations
233260 .def (" f" , f)
261+ .def (" f_mutable_ref" , f_mutable_ref)
262+ .def (" f_mutable_ptr" , f_mutable_ptr)
263+ .def (" f_const_ptr" , f_const_ptr)
234264
265+ .def (" f2" , f2)
266+
235267 // Expose g()
236268 .def (" g" , g , return_value_policy<copy_const_reference>()
237269 )
0 commit comments