将python dict作为地图传递给c ++的问题

时间:2019-01-17 12:51:06

标签: boost-python

我有一个使用

导出到python的c ++类
.gradle

具有功能签名

class_<std::map<std::string, std::string> >("str2str_map")
        .def(map_indexing_suite< std::map<std::string, std::string> > ());

class_< MyClass, boost::noncopyable >("MyClass")
    .def(init<>())
    .def("process", &MyClass::process )

但是,当我尝试从python端调用时,出现错误

  

Boost.Python.ArgumentError:中的Python参数类型       MyClass.process(MyClass,dict,function,int)与C ++签名不匹配:       进程(MyClass {lvalue},std :: map,   std :: allocator>,std :: __ cxx11 :: basic_string,std :: allocator>,   std :: less,   std :: allocator>>,   std :: allocator,std :: allocator> const,   std :: __ cxx11 :: basic_string,   std :: allocator>>>> {lvalue})

我需要怎么做才能使其正常工作?

0 个答案:

没有答案