boost python writing converters for list to std::vector<T>
Hi, using http://misspent.wordpress.com/2009/09/27/how-to-write-boost-python-converter..., I tried to write a converter for list to std::vector<T> (In the example, T will be double). The code (see converter.cxx) I wrote is still in early stage of development (no check) but compiles fine on ubuntu oneiric with boost python 1.46. I used it to create an std module. However, a simple test (see test.py) does not work as exepted. Did I misunderstood something or does boost have a special treatment for the list object which bypasses converters ? Thanks for any help, Sincerly, Helfer THomas
On 04/20/2012 11:45 AM, Helfer Thomas wrote:
Hi,
using http://misspent.wordpress.com/2009/09/27/how-to-write-boost-python-converter..., I tried to write a converter for list to std::vector<T> (In the example, T will be double).
The code (see converter.cxx) I wrote is still in early stage of development (no check) but compiles fine on ubuntu oneiric with boost python 1.46. I used it to create an std module. However, a simple test (see test.py) does not work as exepted.
Did I misunderstood something or does boost have a special treatment for the list object which bypasses converters ?
The problem is that your "print" function takes a std::vector by reference, and you've defined an rvalue converter, which will only match value or const reference arguments. In other words, void print(std::vector<double> const & v) {...} or void print(std::vector<double> v) {...} should work. Everything else looks good. HTH! Jim
participants (2)
-
Helfer Thomas -
Jim Bosch