How to properly wrap std::vector<std::size_t> with SWIG for Python? Problems with std::size_t
Instantiate your templates as follows
namespace std {
%template(VecSize) vector<size_t>;
}
It works here with this change - out of the box. I am using SWIG 3.0.2, g++ 4.9.2 and Python 2.7.9.
I have changed d_swig_vec_std_size.i
in your project and the include path to /usr/include/python2.7
in your makefile
%module d_swig_vec_std_size
%{
#include "class_vec_std_size.hpp"
%}
%include "std_vector.i"
%template(VecInt) std::vector<int>;
%include "std_size_t.i"
namespace std {
%template(VecSize) vector<size_t>;
}
%include "class_vec_std_size.hpp"
Try defining size_t for swig as shown here - http://www.swig.org/Doc1.3/SWIG.html#SWIG_nn20
%inline %{
typedef long unsigned int size_t;
%}
namespace std {
%template(VecSize) vector<size_t>;
}