基本std::使用SWIG将包装映射到Python

基本std::使用SWIG将包装映射到Python,python,swig,Python,Swig,我惊讶地发现,SWIG没有自动包装以下函数。当然,我一定做错了什么,因为这是一个非常基本的例子 接口文件(stdmap.i): 当包装到Python时,我得到 > test_map() <stdmap.map_ii; proxy of <Swig Object of type 'std::map< int,int > *' at 0x10801dd50> > 正如所料。我在哪里犯错误?前面的SWIG+std::map问题有一个答案(),如果您还没有看到

我惊讶地发现,SWIG没有自动包装以下函数。当然,我一定做错了什么,因为这是一个非常基本的例子

接口文件(
stdmap.i
):

当包装到Python时,我得到

> test_map()
<stdmap.map_ii; proxy of <Swig Object of type 'std::map< int,int > *' at 0x10801dd50> >

正如所料。我在哪里犯错误?

前面的SWIG+std::map问题有一个答案(),如果您还没有看到,您可能会觉得很有趣。这意味着std::map在通过SWIG接口时可能无法完美地包装。是的,但最后的注释说:“看起来您甚至不需要在Python代码中使用map\u string\u string类型。声明模板后,SWIG可以自动确定如何将dict转换为它。”。在我的代码中,这是不会发生的。
#include <map>

std::map<int, int> test_map() {
    return {{1, 0}, {4, 5}};
}
> test_map()
<stdmap.map_ii; proxy of <Swig Object of type 'std::map< int,int > *' at 0x10801dd50> >
{1: 0, 4: 5}