[C++-sig] Passing C++ arrays as arguments

Ralf W. Grosse-Kunstleve rwgk at yahoo.com
Mon Nov 18 19:50:31 CET 2002


--- Kerim Borchaev <warkid at hotbox.ru> wrote:
> Can I simply define some from python tuple to float
> [16] converter so
> that I can call object returned from createInstance 
> like this:
> createInstance().f((0,)*16) ?

IIUC, the information about the size is ignored by the compiler. Your
declaration is equivalent to void f(float*). But you can use a thin wrapper
with a boost::array<float, 16> const& in the signature, in combination with the
scitbx container conversion header (which has no dependencies other than
Boost.Python V2).

Here is the header:

http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/cctbx/scitbx/include/scitbx/boost_python/container_conversions.h

Here is a regression test/example:

http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/cctbx/scitbx/array_family/boost_python/regression_test_ext.cpp

Look for, e.g. boost_array_3 and

    scitbx::boost_python::container_conversions::from_python_sequence<
      boost::array<double, 3>,
      scitbx::boost_python::container_conversions::fixed_size_policy>();

Ralf


__________________________________________________
Do you Yahoo!?
Yahoo! Web Hosting - Let the expert host your site
http://webhosting.yahoo.com




More information about the Cplusplus-sig mailing list