Hi all,

I am farily new to boost.python and trying to expose the return value of a
function to python.

The function signature looks like this:

        std::unique_ptr<Message> someFunc(const std::string &str) const;


When calling the function in python, I get the following error:

        TypeError: No to_python (by-value) converter found for C++ type:
std::unique_ptr<Message, std::default_delete<Message> >

My function call in python looks like this:

        a = mymodule.MyClass()
        a.someFunc("some string here") # error here

I tried to expose the smart pointer with the following statements:

        class_<std::unique_ptr<Message, std::default_delete<Message>>,
bost::noncopyable ("Message", init<>()) ;

This example compiles, but I still get the error mentioned above.
Also, I tried to expose the class `Message` itself

        class_<Message>("Message", init<unsigned>())
                .def(init<unsigned, unsigned>()) 
                .def("f", &Message::f)
        ;

Does someone know how to properly expose the pointer class?
Thanks!


_______________________________________________
Cplusplus-sig mailing list
Cplusplus-sig@python.org
https://mail.python.org/mailman/listinfo/cplusplus-sig

Reply via email to