[C++-sig] wrapped std::vector slice affecting items in a python list

Jim Bosch talljimbo at gmail.com
Tue Aug 16 22:41:06 CEST 2011


On 08/16/2011 11:29 AM, Babak Khataee wrote:
> Okay thanks for the info.
>
>     Things are also a lot safer if you only wrap vectors as const; it's
>     exposing the mutators to Python that gets really difficult.
>
>
> Is the const-ness of a wrapped object just a side effect of not exposing
> methods which modify it or is it due to something else more explicit ?

The former.  It's really only the methods that can invalidate iterators 
(i.e. those that add or remove elements) that you need to worry about. 
Non-const access to individual elements is totally safe on its own.

Jim


More information about the Cplusplus-sig mailing list