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})
Everything works with just 'std::string s', but I would like to the object by reference without copying it. I noticed that the error pops up for any other function with references like e.g. int&.