How to get python slicing to work with my c++ array class using SWIG
问题 I have an an array class, Array1D, defined in c++ which essentially wraps the STL vector class. I extended this class so that I can display individual elements of the array vector. Here is the relevant code in my SWIG interface file: namespace std{ %template(dblVector) vector<double>; } %extend Array1D{ double __getitem__(int index) { return (*self)[index]; } } This allows me to access individual elements of the array in python: >>> a = Array1D(10) # creates a c++ vector of length 10 with