23 std::string
vanilla() {
return "Vanilla"; };
26 static std::string static_func1() {
return "WithStatic1"; };
30 static std::string static_func2() {
return "WithStatic2"; };
34 static std::string
static_func() {
return "VanillaStaticMix1"; }
38 static std::string
static_func() {
return "VanillaStaticMix2"; }
51 Base1(
int i) :
i(i) { }
52 int foo() {
return i; }
56 b1.
def(py::init<int>())
57 .def(
"foo", &Base1::foo);
60 Base2(
int i) :
i(i) { }
61 int bar() {
return i; }
65 b2.
def(py::init<int>())
66 .def(
"bar", &Base2::bar);
70 struct Base12 : Base1, Base2 {
71 Base12(
int i,
int j) : Base1(i), Base2(j) { }
73 struct MIType : Base12 {
74 MIType(
int i,
int j) : Base12(i, j) { }
78 .def(py::init<int, int>());
82 #define PYBIND11_BASEN(N) py::class_<BaseN<N>>(m, "BaseN" #N).def(py::init<int>()).def("f" #N, [](BaseN<N> &b) { return b.i + N; }) 103 Base1a(
int i) :
i(i) { }
104 int foo() {
return i; }
108 .def(py::init<int>())
109 .def(
"foo", &Base1a::foo);
112 Base2a(
int i) :
i(i) { }
113 int bar() {
return i; }
117 .def(py::init<int>())
118 .def(
"bar", &Base2a::bar);
120 struct Base12a : Base1a, Base2a {
121 Base12a(
int i,
int j) : Base1a(i), Base2a(j) { }
125 .def(py::init<int, int>());
127 m.
def(
"bar_base2a", [](Base2a *b) {
return b->bar(); });
128 m.
def(
"bar_base2a_sharedptr", [](std::shared_ptr<Base2a> b) {
return b->bar(); });
133 struct I801B1 {
int a = 1; I801B1() =
default; I801B1(
const I801B1 &) =
default;
virtual ~I801B1() =
default; };
134 struct I801B2 {
int b = 2; I801B2() =
default; I801B2(
const I801B2 &) =
default;
virtual ~I801B2() =
default; };
135 struct I801C : I801B1, I801B2 {};
136 struct I801D : I801C {};
138 struct I801B3 {
int c = 3;
virtual ~I801B3() =
default; };
139 struct I801E : I801B3, I801D {};
149 m.
def(
"i801b1_c", [](I801C *c) {
return static_cast<I801B1 *
>(c); });
150 m.
def(
"i801b2_c", [](I801C *c) {
return static_cast<I801B2 *
>(c); });
151 m.
def(
"i801b1_d", [](I801D *
d) {
return static_cast<I801B1 *
>(
d); });
152 m.
def(
"i801b2_d", [](I801D *d) {
return static_cast<I801B2 *
>(
d); });
157 m.
def(
"i801c_b1", []() -> I801B1 * {
return new I801C(); });
158 m.
def(
"i801c_b2", []() -> I801B2 * {
return new I801C(); });
159 m.
def(
"i801d_b1", []() -> I801B1 * {
return new I801D(); });
160 m.
def(
"i801d_b2", []() -> I801B2 * {
return new I801D(); });
164 m.
def(
"i801e_c", []() -> I801C * {
return new I801E(); });
165 m.
def(
"i801e_b2", []() -> I801B2 * {
return new I801E(); });
184 m,
"VanillaStaticMix1")
190 m,
"VanillaStaticMix2")
196 #if !defined(PYPY_VERSION) 198 struct VanillaDictMix1 :
Vanilla, WithDict { };
199 struct VanillaDictMix2 : WithDict,
Vanilla { };
208 struct B {
int b;
B() =
default;
B(
const B&) =
default;
virtual ~
B() =
default; };
209 struct C0 :
public virtual B {
int c0; };
210 struct C1 :
public virtual B {
int c1; };
211 struct D :
public C0,
public C1 {
int d; };
213 .def(
"b", [](
B *
self) {
return self; });
215 .def(
"c0", [](C0 *
self) {
return self; });
217 .def(
"c1", [](
C1 *
self) {
return self; });
class_ & def_readwrite_static(const char *name, D *pm, const Extra &...extra)
test_initializer multiple_inheritance("multiple_inheritance", test_submodule_multiple_inheritance)
Annotation which enables dynamic attributes, i.e. adds __dict__ to a class.
#define PYBIND11_BASEN(N)
static std::string static_func()
static std::string static_func()
static std::string static_func2()
static std::string static_func1()
#define TEST_SUBMODULE(name, variable)
bool typename Extra class_ & def(const char *name_, Func &&f, const Extra &... extra)