[C++-sig] How to deal with array?

Ralf W. Grosse-Kunstleve rwgk at yahoo.com
Sun Jul 3 16:20:18 CEST 2005


--- Clark <foo.Clark at gmail.com> wrote:

> Thanks. I'll try it. And can you give me somthing about other solutions?

Can you change the wrapped classes? If yes, you could use boost::array<int, 4>
instead of the plain C int [4]. The signature of your method would become
set(boost::array<int, 4> const&) instead of set(int*). Then you could use this
file (no dependencies other than Boost):

   
http://cvs.sourceforge.net/viewcvs.py/cctbx/scitbx/include/scitbx/boost_python/container_conversions.h?view=markup

to define automatic list or tuple -> boost::array<int, 4> conversions. I.e. you
could wrap your set method directly. See also:

    http://www.boost.org/libs/python/doc/v2/faq.html#question2

I've mentioned this many times before on this list. Google for
container_conversions to find the messages.

This doesn't support write_back, though (the previous suggestion does).
You could use both what I suggested before and what I am suggesting here at the
same time, I believe.

There is also the vector indexing suite which comes with Boost.Python (see
docs), but this is more for large arrays.

Cheers,
        Ralf


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 



More information about the Cplusplus-sig mailing list