You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a class A and a subclass B, both registered by pybind11.
When enabling C++17 mode, I had to replace B::size with a lambda function, as pybind11 suddenly started tying this to "A", which was previously correctly using the correct thing in C++14 mode. Seems to happen on both GCC and Clang.
Reproducible example code
Might try to build a minimal example later , just wanted to get this in so I don't forget. Change to make tests pass here: scikit-hep/boost-histogram@6c93370 "boolean" is my subclass, and "integer_none" is the previously registered parent. scikit-hep/boost-histogram#502
Is B::size marked noexcept? If it is, that's a known issue and requires rewriting some of pybind's custom type traits. Also, if my assumption is correct, this is a duplicate of #2234 and #2666
Assuming I have not missed anything, these are the things that need updating:
cpp_function
class_::def_buffer
detail::remove_class
detail::initimpl::factory
The first three are easy. The initimpl::factory is related to py::init as the return type. I don't know if it would break anything else, but initimpl::factory could be fixed by stripping noexcept in py::detail::function_signature_t.
Fixed by #5992 (in v3.1.0). method_adaptor now rebinds noexcept member function pointers from a base class to the derived class, so &B::size binds with B as self in C++17. Duplicate of #2234.
Activity
bstaletic commentedon Feb 11, 2021
Is
B::sizemarkednoexcept? If it is, that's a known issue and requires rewriting some of pybind's custom type traits. Also, if my assumption is correct, this is a duplicate of #2234 and #2666henryiii commentedon Feb 11, 2021
Yes, it is:
https://github.com/boostorg/histogram/blob/ff188c61f66844ad4907d128197feb3c8d0e5fe9/include/boost/histogram/axis/integer.hpp#L148-L149
bstaletic commentedon Feb 24, 2021
Assuming I have not missed anything, these are the things that need updating:
cpp_functionclass_::def_bufferdetail::remove_classdetail::initimpl::factoryThe first three are easy. The
initimpl::factoryis related topy::initas the return type. I don't know if it would break anything else, butinitimpl::factorycould be fixed by strippingnoexceptinpy::detail::function_signature_t.EDIT: There's also
method_adaptorvectorizeSkylion007 commentedon Mar 28, 2023
detail::remove_classhas been dealt with partially in #4593 . That turned out to be enough to allow for noexcept lambdas.henryiii commentedon Nov 12, 2026
🤖 AI text below 🤖
Fixed by #5992 (in v3.1.0).
method_adaptornow rebindsnoexceptmember function pointers from a base class to the derived class, so&B::sizebinds withBasselfin C++17. Duplicate of #2234.