[C++-sig] Boost.Python indexing suite version 2?
Matthew Scouten (TT)
Matthew.Scouten at tradingtechnologies.com
Thu Jul 23 17:59:01 CEST 2009
This is a sketch of what I want to do. This seems to work seamlessly
with the
included indexing suite. I cannot figure out how the make it work with
the advanced one.
---------------------- c++
----------------------------------------------
struct foo
{
int bar;
};
class_<foo>("foo")
.def_readwrite("bar", &foo::bar)
;
#if 1
//this does not work the way I want
class_< std::vector<foo> >("class_< std::vector<foo> >("VectorOfFoo") )
.def( indexing::container_suite< std::vector<foo> >() )
;
#else
//I think this should work the way I want, but it will not compile.
class_< std::vector<foo> >("VectorOfFoo")
.def( indexing::container_proxy< std::vector<foo> >() )
;
#endif
----------------------Python--------------------------------------------
--
v = VectorOfFoo()
f = foo()
f.bar = 0
v.append(f)
assert v[0].bar == 0
v[0].bar = 10 #This returns the foo by value. That does not happen with
the bp::vector_indexing_suite.
assert v[0].bar == 10 # this fails. v[0].bar is still 0
-----Original Message-----
From:
cplusplus-sig-bounces+matthew.scouten=tradingtechnologies.com at python.org
[mailto:cplusplus-sig-bounces+matthew.scouten=tradingtechnologies.com at py
thon.org] On Behalf Of Roman Yakovenko
Sent: Wednesday, July 22, 2009 11:57 PM
To: Development of Python/C++ integration
Subject: Re: [C++-sig] Boost.Python indexing suite version 2?
On Wed, Jul 22, 2009 at 11:00 PM, Matthew Scouten
(TT)<Matthew.Scouten at tradingtechnologies.com> wrote:
> I am looking into whether this will satisfy my needs. It looks good so
> far but I have a question:
> How am I supposed to use container_proxy? The only thing given for an
> example is a link to an empty file. Using it as a drop-in replacement
> for container_suite does not work.
Unfortunately, I never used this class before. If you will send
**small and complete** example of what you are trying to do, I will
take a look on it.
--
Roman Yakovenko
C++ Python language binding
http://www.language-binding.net/
_______________________________________________
Cplusplus-sig mailing list
Cplusplus-sig at python.org
http://mail.python.org/mailman/listinfo/cplusplus-sig
More information about the Cplusplus-sig
mailing list