@@ -30,41 +30,42 @@ PYBIND11_NAMESPACE_END(PYBIND11_NAMESPACE)
30
30
// BOILERPLATE END
31
31
32
32
namespace {
33
- struct Foo0 {};
34
- struct Foo1 {};
35
- struct Foo2 {};
36
- struct Foo3 {};
37
- struct Foo4 {};
33
+ struct FooUc {};
34
+ struct FooUp {};
35
+ struct FooSa {};
36
+ struct FooSc {};
37
+ struct FooSp {};
38
38
} // namespace
39
39
40
- PYBIND11_TYPE_CASTER_BASE_HOLDER (Foo1, std::shared_ptr<Foo1>)
41
- PYBIND11_SMART_HOLDER_TYPE_CASTERS(Foo2)
42
- PYBIND11_SMART_HOLDER_TYPE_CASTERS(Foo4)
40
+ PYBIND11_SMART_HOLDER_TYPE_CASTERS (FooUp)
41
+ PYBIND11_SMART_HOLDER_TYPE_CASTERS(FooSp)
42
+
43
+ PYBIND11_TYPE_CASTER_BASE_HOLDER(FooSa, std::shared_ptr<FooSa>)
43
44
44
45
TEST_SUBMODULE(classh_mock, m) {
45
46
// Please see README_smart_holder.rst, in particular section
46
47
// Classic / Conservative / Progressive cross-module compatibility
47
48
48
- // Uses std::unique_ptr<Foo0> as holder in Conservative mode, py::smart_holder in Progressive
49
- // mode (if available).
50
- py::class_<Foo0>(m, " Foo0" ).def (py::init<>());
51
-
52
- // Always uses std::shared_ptr<Foo1> as holder.
53
- py::class_<Foo1, std::shared_ptr<Foo1>>(m, " Foo1" ).def (py::init<>());
49
+ // Uses std::unique_ptr<FooUc> as holder in Classic or Conservative mode, py::smart_holder in
50
+ // Progressive mode.
51
+ py::class_<FooUc>(m, " FooUc" ).def (py::init<>());
54
52
55
- // Uses std::shared_ptr<Foo2 > as holder in Classic mode, py::smart_holder in Conservative or
53
+ // Uses std::unique_ptr<FooUp > as holder in Classic mode, py::smart_holder in Conservative or
56
54
// Progressive mode.
57
- py::class_<Foo2, PYBIND11_SH_AVL (Foo2)>(m, " Foo2" ).def (py::init<>());
58
- // ------------- std::shared_ptr<Foo2> -- same length by design, to not disturb the indentation
59
- // of existing code.
55
+ py::classh<FooUp>(m, " FooUp" ).def (py::init<>());
60
56
61
- // Uses std::shared_ptr<Foo3> as holder in Classic or Conservative mode, py::smart_holder in
57
+ // Always uses std::shared_ptr<FooSa> as holder.
58
+ py::class_<FooSa, std::shared_ptr<FooSa>>(m, " FooSa" ).def (py::init<>());
59
+
60
+ // Uses std::shared_ptr<FooSc> as holder in Classic or Conservative mode, py::smart_holder in
62
61
// Progressive mode.
63
- py::class_<Foo3 , PYBIND11_SH_DEF (Foo3 )>(m, " Foo3 " ).def (py::init<>());
64
- // ------------- std::shared_ptr<Foo3 > -- same length by design, to not disturb the indentation
65
- // of existing code.
62
+ py::class_<FooSc , PYBIND11_SH_DEF (FooSc )>(m, " FooSc " ).def (py::init<>());
63
+ // -------------- std::shared_ptr<FooSc > -- same length by design, to not disturb the
64
+ // indentation of existing code.
66
65
67
- // Uses py::smart_holder if available, or std::unique_ptr<Foo3> if only pybind11 Classic is
68
- // available.
69
- py::classh<Foo4>(m, " Foo4" ).def (py::init<>());
66
+ // Uses std::shared_ptr<FooSp> as holder in Classic mode, py::smart_holder in Conservative or
67
+ // Progressive mode.
68
+ py::class_<FooSp, PYBIND11_SH_AVL (FooSp)>(m, " FooSp" ).def (py::init<>());
69
+ // -------------- std::shared_ptr<FooSp> -- same length by design, to not disturb the
70
+ // indentation of existing code.
70
71
}
0 commit comments