Open
Description
Hello,
I encountered the problem with method returning std::unique_ptr. When exposed without trampoline class, everything works, however when trampoline class is involved, the code does not compile and compiler complains for missing type_caster. The behavior is illustrated on attached minimal example.
#include <pybind11/pybind11.h>
#include <pybind11/operators.h>
namespace py = pybind11;
class Status {
public:
Status() {}
};
class Factory {
public:
Factory() {}
virtual std::unique_ptr<Status> GetStatus() const {
return std::unique_ptr<Status> (new Status);
}
};
template <class FactoryBase = Factory> class PyFactory: public FactoryBase {
public:
using FactoryBase::FactoryBase;
std::unique_ptr<Status> GetStatus() const override {
PYBIND11_OVERLOAD(std::unique_ptr<Status> , FactoryBase, GetStatus, );
}
};
PYBIND11_MODULE(demo2, m) {
py::class_<Status>(m, "Status")
.def(py::init<>())
;
py::class_<Factory, PyFactory<>>(m, "Factory")
.def(py::init<>())
.def("GetStatus", &Factory::GetStatus)
;
}
Metadata
Metadata
Assignees
Labels
No labels