std Vector

/* stdVector.h */
#include<vector>
#include <iostream>
void mostrar(std::vector<int> v){
	std::vector<int>::iterator i;
	for( i = v.begin() ; i != v.end(); i++)
		std::cout << *i << std::endl;
}
%module stdVector
%{
#include "stdVector.h"
%}

%include "std_vector.i"
namespace std{
   %template(IntVector) vector<int>;
   %template(DoubleVector) vector<double>;
 };

%include "stdVector.h"
#!/usr/bin/env python
"""
setup.py file for SWIG stdVector
"""
from distutils.core import setup, Extension
stdVector_module = Extension('_stdVector',
                           sources=['stdVector_wrap.cxx']
                           )
setup (name = 'stdVector',
       version = '0.1',
       author      = "SWIG Docs",
       description = """Simple swig stdVector from docs""",
       ext_modules = [stdVector_module],
       py_modules = ["stdVector"],
       )

Para crear el modulo

all: stdVector.h stdVector.i setup.py
	swig -c++ -python stdVector.i
	python stdVectorSetup.py build_ext --inplace

Para testear el modulo

#!/usr/bin/python
# -*- coding: utf-8 -*-
import stdVector
vec = stdVector.IntVector(4)
for i in range(0,len(vec)):
	vec[i]= i*10
stdVector.mostrar(vec)
print
stdVector.mostrar(stdVector.IntVector([10,20,40]))
print
stdVector.mostrar([5,10,15])