I was surprised to find that the following function is not automatically wrapped by SWIG. Surely, I must have done something wrong, as it is a very basic example.
Interface file (stdmap.i
):
%module stdmap;
%include "std_map.i"
%template(map_ii) std::map<int, int>;
%{
extern std::map<int, int> test_map();
%}
extern std::map<int, int> test_map();
Implementation (stdmap.cpp
):
#include <map>
std::map<int, int> test_map() {
return {{1, 0}, {4, 5}};
}
When wrapping to Python, I get
> test_map()
<stdmap.map_ii; proxy of <Swig Object of type 'std::map< int,int > *' at 0x10801dd50> >
and not
{1: 0, 4: 5}
as expected. Where do I make a mistake?