-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Closed
Description
Not sure if this is a bug or intended behavior: it looks like detail::is_accessible_base_of seems give false negative for union
types. Here the minimal example to reproduce and an error.
Thanks,
#include <pybind11/pybind11.h>
union A
{
int i;
float f;
};
PYBIND11_MODULE(example, m) {
A a, b;
a = b; // work fine!
pybind11::class_< A > (m, "A")
.def(pybind11::init<>() )
.def("assign", (A & (A::*)(const A &)) &A::operator=); // trigger static assert
;
}
Error:
In file included from union.cpp:1:
/home/benchmark/src/pybind11/include/pybind11/pybind11.h:1000:5: error: static_assert failed "Cannot bind an inaccessible base class method; use a lambda definition instead"
static_assert(detail::is_accessible_base_of<Class, Derived>::value,
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/benchmark/src/pybind11/include/pybind11/pybind11.h:1085:25: note: in instantiation of function template specialization 'pybind11::method_adaptor<A, A &, A, const A &>' requested here
cpp_function cf(method_adaptor<type>(std::forward<Func>(f)), name(name_), is_method(*this),
^
union.cpp:16:4: note: in instantiation of function template specialization 'pybind11::class_<A>::def<A &(A::*)(const A &)>' requested here
.def("assign", (A & (A::*)(const A &)) &A::operator=); // trigger static assert
^
1 error generated.
Metadata
Metadata
Assignees
Labels
No labels