Open rhaschke opened 6 years ago
I want to wrap C++ code that only provides const access to a class Foo:
const
Foo
struct Foo {}; std::shared_ptr<const Foo> producer();
Wrapping Foo as usual:
BOOST_PYTHON_MODULE(foo) { boost::python::class_<Foo, std::shared_ptr<Foo>, boost::noncopyable>("Foo", boost::python::no_init); boost::python::def("producer", &producer); }
compiles fine, but complains at runtime - obviously - about a missing type converter: No to_python (by-value) converter found for C++ type: std::shared_ptr<Foo const>
No to_python (by-value) converter found for C++ type: std::shared_ptr<Foo const>
Alternatively trying:
BOOST_PYTHON_MODULE(foo) { // const holder boost::python::class_<Foo, std::shared_ptr<const Foo>, boost::noncopyable>("Foo", boost::python::no_init); // const class + holder boost::python::class_<const Foo, std::shared_ptr<const Foo>, boost::noncopyable>("Foo", boost::python::no_init); }
yields compile-time errors about constness issues. Isn't there a solution available that respects constness?
Same problem here , was any solution found?
I switched to pybind11, which is a more modern and faster wrapper.
I want to wrap C++ code that only provides
const
access to a classFoo
:Wrapping
Foo
as usual:compiles fine, but complains at runtime - obviously - about a missing type converter:
No to_python (by-value) converter found for C++ type: std::shared_ptr<Foo const>
Alternatively trying:
yields compile-time errors about constness issues. Isn't there a solution available that respects constness?