[C++-sig] Re: Howto wrap operator[]? (boost::python)

David Abrahams dave at boost-consulting.com
Fri Jun 13 21:44:20 CEST 2003


"Neal D. Becker" <nbecker at hns.com> writes:

> I am playing with exposing std::vector<double>.  So far I got init
> OK, now I want to expose operator[].  I don't see anything in the
> tutorial about this.  Any hints?

You just need to wrap some functions as __getitem__ and __setitem__.
There's a whole thread about pitfalls with this here:

http://aspn.activestate.com/ASPN/Mail/Message/c++-sig/1652155

You're not subject to most of the problems, because double isn't a
class type.

-- 
Dave Abrahams
Boost Consulting
www.boost-consulting.com





More information about the Cplusplus-sig mailing list