Boost Python: Error when passing variable by reference in a function
问题 I would like to understand why the following function does not work in python: #include<boost/python.hpp> #include<iostream> #include<string> void hello(std::string& s) { std::cout << s << std::endl; } BOOST_PYTHON_MODULE(test) { boost::python::def("hello", hello); } When I import library into python import test test.hello('John') I get an error: test.hello(str) did not match C++ signature: hello(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > {lvalue})