boost-python-examples icon indicating copy to clipboard operation
boost-python-examples copied to clipboard

The necessity of exporting base virtual function in 06-VirtualFunctionsInPython

Open ivytin opened this issue 4 years ago • 0 comments

In https://github.com/TNG/boost-python-examples/blob/72ea66d3e6200f8bcbaac707069ba708d88d8ee8/06-VirtualFunctionsInPython/virtual.cpp#L36

I knew the boost python doc said

Take note that we expose both &Base::f and &BaseWrap::default_f. Boost.Python needs to keep track of 1) the dispatch function f and 2) the forwarding function to its default implementation default_f. There's a special def function for this purpose.

But is it truely necessary to export &Base::name? And I can't see the differences blow in running results:

.def("name", &Base::name, &BaseWrap::default_name)
.def("name", &BaseWrap::default_name)

ivytin avatar May 12 '21 11:05 ivytin