[C++-sig] def_readonly and const array members
Ralf W. Grosse-Kunstleve
rwgk at yahoo.com
Fri Jul 25 03:05:35 CEST 2003
--- Jeff Brewer <jeff at brewer.com> wrote:
> I am trying to wrap structs that have character arrays and I'm having
> problems since I moved from MSVC 7 to MSVC 7.1 (VS .NET 2003). Here is
> the struct I'm trying to expose the theArray member of using
> class_::def_readonly:
Are you also moving to a more recent boost?
> .def_readonly("theArray", &testStruct::theArray);
Try this instead:
#include <boost/python/return_value_policy.hpp>
#include <boost/python/return_by_value.hpp>
.add_property("theArray", make_getter(&testStruct::theArray,
return_value_policy<return_by_value>()));
If you want to support both Boost 1.29 and never versions:
#include <boost/version.hpp>
#if BOOST_VERSION >= 103000
// use add_property
#else
// use def_readonly or def_readwrite
#endif
Ralf
__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com
More information about the Cplusplus-sig
mailing list