[C++-sig] Re: def_readonly and const array members
Jeff Brewer
jeff at brewer.com
Sun Jul 27 06:43:14 CEST 2003
Sorry about the error message difference - nothing funny is going on. I
tested with an 8 character array first and then a 16. I included the
error message from the 8 try. I'll try it with an int array and post the
results.
Jeff Brewer
-----Original Message-----
From: Ralf W. Grosse-Kunstleve [mailto:rwgk at yahoo.com]
Posted At: Friday, July 25, 2003 9:00 AM
Posted To: c++-sig
Conversation: [C++-sig] Re: def_readonly and const array members
Subject: Re: [C++-sig] Re: def_readonly and const array members
--- David Abrahams <dave at boost-consulting.com> wrote:
> "Jeff Brewer" <jeff at brewer.com> writes:
>
> > I am using Boost 1.30. Sorry I forgot to mention that.
> >
> > def_readonly seems to still in 1.30 and its implementation is:
> > template <class D, class B>
> > self& def_readonly(char const* name, D B::*pm_)
> > {
> > D T::*pm = pm_;
> > this->add_property(name, make_getter(pm));
> > return *this;
> > }
> > Is it deprecated though?
>
> Nope. I don't have time to figure out why this isn't working for you
> right now, but...
If David cannot figure it out, maybe it is time to admit that I am
lost, too. I am doing all the time what you are trying to do, under
many platforms including Visual C++ 7.1. However, I've never tried
it with char arrays. What happens if you change your small test to
work with, say, int instead of char?
I am not sure it will help, but here is my "to_tuple" converter:
template <typename ContainerType>
struct to_tuple
{
static PyObject* convert(ContainerType const& a)
{
boost::python::list result;
for(std::size_t i=0;i<a.size();i++) {
result.append(boost::python::object(a[i]));
}
return boost::python::incref(boost::python::tuple(result).ptr());
}
};
Your's looks good, too, but maybe there is a subtlety that VC chokes on?
I also noticed that your test involves char array[16], but you quote an
error message related to char array[8]? Where does that factor of two
come from?
OK, enough shots in the blue for now. Hope this is useful somehow.
Ralf
__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com
_______________________________________________
C++-sig mailing list
C++-sig at python.org
http://mail.python.org/mailman/listinfo/c++-sig
More information about the Cplusplus-sig
mailing list