-
Hi, I have a simple interface consist of three abstract classes /home/kerim/Documents/tmp/pybind11/include/pybind11/detail/common.h: In instantiation of ‘struct pybind11::detail::exactly_one<pybind11::class_<B, BImpl<B>, AImpl<B> >::is_subtype, void, BImpl<B>, AImpl<B> >’:
/home/kerim/Documents/tmp/pybind11/include/pybind11/detail/common.h:716:7: required by substitution of ‘template<template<class> class Predicate, class Default, class ... Ts> using exactly_one_t = typename pybind11::detail::exactly_one::type [with Predicate = pybind11::class_<B, BImpl<B>, AImpl<B> >::is_subtype; Default = void; Ts = {BImpl<B>, AImpl<B>}]’
/home/kerim/Documents/tmp/pybind11/include/pybind11/pybind11.h:1335:11: required from ‘class pybind11::class_<B, BImpl<B>, AImpl<B> >’
/home/kerim/Documents/tmp/pybind11/templated_interface/main.cpp:31:12: required from here
/home/kerim/Documents/tmp/pybind11/include/pybind11/detail/common.h:707:25: error: static assertion failed: Found more than one type matching the predicate
707 | static_assert(found <= 1, "Found more than one type matching the predicate"); I uploaded the minimal project with these classes. It is small cmake project and you can choose whether to build pybind module or executable (by commenting appropriate blocks in main.cpp: #include "a.h"
#include "b.h"
#include "c.h"
#include <pybind11/pybind11.h>
namespace py = pybind11;
int main(int argc, char *argv[])
{
createA()->a();
createB()->b();
createC()->c();
return 0;
}
// comment this pybind section and the project will be normally compiled
PYBIND11_MODULE(example, m) {
auto a = py::class_<
A,
AImpl<A>>
(m, "A")
.def("A", &A::a);
auto b = py::class_<
B,
BImpl<B>,
AImpl<B>>
(m, "B")
.def("B", &B::b);
auto c = py::class_<
C,
CImpl<C>,
BImpl<C>,
AImpl<C>>
(m, "C")
.def("C", &C::c);
} Appreciate any help! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
It seems that I did wrong inheritance structure in pybind module. I should have rather inherit from interfaces: PYBIND11_MODULE(example, m) {
auto a = py::class_<
A,
AImpl<A>>
(m, "A")
.def("A", &A::a);
auto b = py::class_<
B,
BImpl<B>,
A>
(m, "B")
.def("B", &B::b);
auto c = py::class_<
C,
CImpl<C>,
B,
A>
(m, "C")
.def("C", &C::c);
} |
Beta Was this translation helpful? Give feedback.
It seems that I did wrong inheritance structure in pybind module. I should have rather inherit from interfaces: