add Base class bind function in LocalViewWrapper
LocalViewWrapper from class def does not allow calling the inherited C++ bind function similar to the MVE https://godbolt.org/z/f86c891cP.
My use case is the following:
I want to hand out a bound localView
to python. In use of LocalViewWrapper a LocalViewWrapper is handed out.
Thus, if I have a bound localView and I want it to forward to python. Currently, I'm doing
cls.def(
"localView", [](A& self) -> LocalViewWrapper{
auto lvWrapped = LocalViewWrapper(self.localView().globalBasis());
pybind11::object obj = pybind11::cast(self.localView().element());
lvWrapped.bind(obj);
return lvWrapped; } , pybind11::keep_alive< 0, 1 >());
What this PR allows to do: (Due to the new constructor)
cls.def(
"localView", [](A& self) -> LocalViewWrapper{
return LocalViewWrapper(self.localView()); } , pybind11::keep_alive< 0, 1 >());
or (Due to the base class bind function)
cls.def(
"localView", [](A& self) -> LocalViewWrapper{
auto lvWrapped = LocalViewWrapper(self.localView().globalBasis());
lvWrapped.bind(self.localView().element());
return lvWrapped; } , pybind11::keep_alive< 0, 1 >());
I hope this is a correct suggestions. Thanks!