使用 Boost.Python,我似乎无法绑定任何返回 const char* 示例的函数:
class Bar
{
private:
int x;
public:
Bar():x(0){}
Bar(int x) : x(x) {}
int get_x() const { return x; }
void set_x(int x) { this->x = x; }
const char *get_str(){return "hello";}
};
BOOST_PYTHON_MODULE(internal_refs)
{
class_<Bar>("Bar")
.def("get_x", &Bar::get_x)
.def("set_x", &Bar::set_x)
.def("get_str", &Bar::get_str, return_internal_reference<>())
;
}
我收到以下错误:
/usr/local/include/boost/python/object/make_instance.hpp:27:9: error: no matching function for call to ‘assertion_failed(mpl_::failed************ boost::mpl::or_<boost::is_class<char>, boost::is_union<char>, mpl_::bool_<false>, mpl_::bool_<false>, mpl_::bool_<false> >::************)’