我正在用boost.python库编写应用程序。我想将函数传递给Python返回std::vector
。我有一个小麻烦:如何导出std :: vector
inline std::vector<std::string> getConfigListValue(const std::string &key)
{
return configManager().getListValue(key);
}
BOOST_PYTHON_MODULE(MyModule)
{
bp::def("getListValue", getListValue);
}
当我调用该函数从蟒蛇,我得到:
TypeError: No to_python (by-value) converter found for C++ type: std::vector<std::string, std::allocator<std::string> >
有什么我错过了?
非常感谢,它的工作原理。 – Ockonal 2011-03-15 16:27:41
顺便说一句,你为什么在'std :: allocator'之前写'class'? – Ockonal 2011-03-15 16:30:09
....我真的不知道!我删除它,它仍然有效 – 2011-03-15 16:33:58