Boost logo

Boost :

From: rwgk_at_[hidden]
Date: 2001-05-03 19:02:16

I do not know the answer to your question regarding your wrapper
idea. Have you tried this and it failed?

I do, however, have another suggestion: You could also use
the method demonstrated in do_it_yourself_converters.cpp.
Related code that could serve as an example:


If you just want to map to and from native Python types,
this should work fine.

Another alternative to consider is to wrap vector<yourchoice>
in the standard way and provide an explicit ".as_tuple()"
method. You could use the cross-module support to use this
in more than one extension module. This approach is more
heavy-weight, but avoids mapping to and from native
Python types unless you explicitly request this. If your
vectors are large, this could be a significant overhead.


--- In boost_at_y..., rcspython_at_y... wrote:
> I have looked at the simple_vector.cpp file. My question is how do
> you actually incorporate this functionality into an existing class?
> I very much want to return a vector from MY C++ class.
> I have a private member
> std::vector<double> myvect;
> Do I have to vector_double_wrapper myvect; instead?
> And then...
> public:
> vector_double_wrapper GetVector(void){ return myvect;};
> Then add this to the class myclass.def(GetVector,"GetVector")?
> I appreciate that I cannot simply return a raw vector but and not
> sure about how to hook up the plumbing.
> I am having a terrible mental block... don't laugh. ;p
> Thanks,
> Ron

Boost list run by bdawes at, gregod at, cpdaniel at, john at