[C++-sig] efficient vector wrapping

Neal D. Becker ndbecker2 at verizon.net
Wed Apr 21 19:53:39 CEST 2004

I'm using vector_indexing_suite to wrap stl::vector.

Suppose I have a function F, which outputs to a vector like so:

void F (std::vector& out);

Suppose in python I want the output to be written to a slice of a vector, so
that there is an offset "d" from the start of the python vector.

With stl-style iterators this would be trivial, but this is python, not c++.

One possibility is:

v1 = vector (10)
d = 2
F (v1)
v2 = vector (len(v1)+d)
v2[d:] = v1

Is there a more efficient, and still python-friendly, approach?

More information about the Cplusplus-sig mailing list