[C++-sig] Re: def_readonly and const array members

Ralf W. Grosse-Kunstleve rwgk at yahoo.com
Fri Jul 25 17:59:51 CEST 2003


--- 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




More information about the Cplusplus-sig mailing list