[C++-sig] C++ const -> Python immutable?

Ralf W. Grosse-Kunstleve rwgk at yahoo.com
Wed Sep 25 15:29:37 CEST 2002

Consider a simple C++ array type, e.g. boost::array, and member functions of
some class that return such arrays.

boost::array<int, 3>& by_reference();
boost::array<int, 3> const& by_const_reference() const;


.def("by_reference", &w_t::by_reference, return_internal_reference<>())
.def("by_const_reference", &w_t::by_const_reference,

Of course, what I was hoping for naively is that the "by_reference" array
behaves similar to a Python list (is mutable) and the "by_const_reference"
array behaves similar to a Python tuple (is immutable). However, my limited
experiments only resulted in "bad argument type for built-in operation" for
"by_const_reference." Is there a return_internal_const_reference policy that I
have overlooked?


Do you Yahoo!?
New DSL Internet Access from SBC & Yahoo!

More information about the Cplusplus-sig mailing list