[C++-sig] directly modifying objects contained in vector exposed with vector_indexing_suite
Roger Dahl
rogerdahl at dahlsys.com
Sat Feb 2 04:29:54 CET 2008
Hello everyone,
I'm having a problem with vector_indexing_suite and thought I'd see if
anyone could tell me if what I'm trying to do should work...
I have exposed a vector<obj> with vector_indexing_suite and a function
that returns a reference to vector<obj> to Python and I'm trying to
update the members of obj from Python.
I can do:
obj = get_vec()[0]
And I can then successfully modify obj:
obj.text = 'test'
However, if I try to modify the object in the vector:
get_vec()[0].text = 'test'
It doesn't "take". After assignment, if I display the value:
print get_vec()[0].text
It just prints the value that "text" had before.
I have tried some variations like passing true for the
vector_indexing_suite NoProxy parameter and having the get_vec function
use return_value_policy<reference_existing_object>. I have also tried to
modify obj in two steps:
obj = get_vec()[0]
obj.text = 'test'
get_vec()[0] = obj
But this also fails silently.
Any pointers would be much appreciated.
Thank you,
Roger
More information about the Cplusplus-sig
mailing list