[C++-sig] Container Conversions: Wrapping Functions Expecting Non-const References

Ralf W. Grosse-Kunstleve rwgk at yahoo.com
Mon Aug 25 11:48:54 CEST 2008

Hi Paul,

> Here I have difficulties:
> Boost.Python.ArgumentError: Python argument types in
>     ContainersExample2.doubleVectorOfInts(ContainersExample2, list)
> did not match C++ signature:
>     doubleVectorOfInts(class ContainersExample2 {lvalue}, class
> std::vector<int,class std::allocator<int> > {lvalue})
> What's the recommended technique(s) for this situation?

Boost.Python doesn't have "on-the-fly converters with write-back" (long story).

You have to wrap std::vector<int> "properly" if you want to pass non-const references to C++.
The vector-indexing suite is an option that should work well. Or you can follow this more
minimalistic example:


Ignore the ref_from_array code near the bottom.


More information about the Cplusplus-sig mailing list