@@ -230,4 +230,87 @@ TEST_SUBMODULE(multiple_inheritance, m) {
230230 .def (" c1" , [](C1 *self) { return self; });
231231 py::class_<D, C0, C1>(m, " D" )
232232 .def (py::init<>());
233+
234+ // test_another_diamond_*
235+ // - functions are get_{base}_{var}, return {var}
236+ struct MVB {
237+ MVB () = default ;
238+ MVB (const MVB&) = default ;
239+ virtual ~MVB () = default ;
240+
241+ int b = 1 ;
242+ int get_b_b () const { return b; }
243+ };
244+ struct MVC : virtual MVB {
245+ int c = 2 ;
246+ int get_c_b () const { return b; }
247+ int get_c_c () const { return c; }
248+ };
249+ struct MVD0 : virtual MVC {
250+ int d0 = 3 ;
251+ int get_d0_b () const { return b; }
252+ int get_d0_c () const { return c; }
253+ int get_d0_d0 () const { return d0; }
254+ };
255+ struct MVD1 : virtual MVC {
256+ int d1 = 4 ;
257+ int get_d1_b () const { return b; }
258+ int get_d1_c () const { return c; }
259+ int get_d1_d1 () const { return d1; }
260+ };
261+ struct MVE : virtual MVD0, virtual MVD1 {
262+ int e = 5 ;
263+ int get_e_b () const { return b; }
264+ int get_e_c () const { return c; }
265+ int get_e_d0 () const { return d0; }
266+ int get_e_d1 () const { return d1; }
267+ int get_e_e () const { return e; }
268+ };
269+ struct MVF : virtual MVE {
270+ int f = 6 ;
271+ int get_f_b () const { return b; }
272+ int get_f_c () const { return c; }
273+ int get_f_d0 () const { return d0; }
274+ int get_f_d1 () const { return d1; }
275+ int get_f_e () const { return e; }
276+ int get_f_f () const { return f; }
277+ };
278+ py::class_<MVB>(m, " MVB" , py::multiple_inheritance ())
279+ .def (py::init<>())
280+ .def (" get_b_b" , &MVB::get_b_b)
281+ .def_readwrite (" b" , &MVB::b);
282+ py::class_<MVC, MVB>(m, " MVC" , py::multiple_inheritance ())
283+ .def (py::init<>())
284+ .def (" get_c_b" , &MVC::get_c_b)
285+ .def (" get_c_c" , &MVC::get_c_c)
286+ .def_readwrite (" c" , &MVC::c);
287+ py::class_<MVD0, MVC>(m, " MVD0" , py::multiple_inheritance ())
288+ .def (py::init<>())
289+ .def (" get_d0_b" , &MVD0::get_d0_b)
290+ .def (" get_d0_c" , &MVD0::get_d0_c)
291+ .def (" get_d0_d0" , &MVD0::get_d0_d0)
292+ .def_readwrite (" d0" , &MVD0::d0);
293+ py::class_<MVD1, MVC>(m, " MVD1" , py::multiple_inheritance ())
294+ .def (py::init<>())
295+ .def (" get_d1_b" , &MVD1::get_d1_b)
296+ .def (" get_d1_c" , &MVD1::get_d1_c)
297+ .def (" get_d1_d1" , &MVD1::get_d1_d1)
298+ .def_readwrite (" d1" , &MVD1::d1);
299+ py::class_<MVE, MVD0, MVD1>(m, " MVE" , py::multiple_inheritance ())
300+ .def (py::init<>())
301+ .def (" get_e_b" , &MVE::get_e_b)
302+ .def (" get_e_c" , &MVE::get_e_c)
303+ .def (" get_e_d0" , &MVE::get_e_d0)
304+ .def (" get_e_d1" , &MVE::get_e_d1)
305+ .def (" get_e_e" , &MVE::get_e_e)
306+ .def_readwrite (" e" , &MVE::e);
307+ py::class_<MVF, MVE>(m, " MVF" , py::multiple_inheritance ())
308+ .def (py::init<>())
309+ .def (" get_f_b" , &MVF::get_f_b)
310+ .def (" get_f_c" , &MVF::get_f_c)
311+ .def (" get_f_d0" , &MVF::get_f_d0)
312+ .def (" get_f_d1" , &MVF::get_f_d1)
313+ .def (" get_f_e" , &MVF::get_f_e)
314+ .def (" get_f_f" , &MVF::get_f_f)
315+ .def_readwrite (" f" , &MVF::f);
233316}
0 commit comments