@@ -20,6 +20,7 @@ namespace class_sh_void_ptr_capsule {
20
20
// Conveniently, the helper also serves to keep track of `capsule_generated`.
21
21
struct HelperBase {
22
22
HelperBase () = default ;
23
+ HelperBase (const HelperBase &) = delete ;
23
24
virtual ~HelperBase () = default ;
24
25
25
26
bool capsule_generated = false ;
@@ -45,7 +46,7 @@ struct NoConversion: public HelperBase {
45
46
};
46
47
47
48
struct NoCapsuleReturned : public HelperBase {
48
- int get () const { return 103 ; }
49
+ int get () const override { return 103 ; }
49
50
50
51
PyObject* as_pybind11_tests_class_sh_void_ptr_capsule_NoCapsuleReturned () {
51
52
capsule_generated = true ;
@@ -72,7 +73,7 @@ int get_from_valid_capsule(const Valid* c) {
72
73
return c->get ();
73
74
}
74
75
75
- int get_from_shared_ptr_valid_capsule (std::shared_ptr<Valid> c) {
76
+ int get_from_shared_ptr_valid_capsule (const std::shared_ptr<Valid> & c) {
76
77
return c->get ();
77
78
}
78
79
@@ -109,7 +110,7 @@ TEST_SUBMODULE(class_sh_void_ptr_capsule, m) {
109
110
.def (py::init<>())
110
111
.def (" as_pybind11_tests_class_sh_void_ptr_capsule_Valid" ,
111
112
[](HelperBase* self) {
112
- Valid * obj = dynamic_cast <Valid *>(self);
113
+ auto obj = dynamic_cast <Valid *>(self);
113
114
assert (obj != nullptr );
114
115
PyObject* capsule = obj->as_pybind11_tests_class_sh_void_ptr_capsule_Valid ();
115
116
return pybind11::reinterpret_steal<py::capsule>(capsule);
@@ -122,7 +123,7 @@ TEST_SUBMODULE(class_sh_void_ptr_capsule, m) {
122
123
.def (py::init<>())
123
124
.def (" as_pybind11_tests_class_sh_void_ptr_capsule_NoCapsuleReturned" ,
124
125
[](HelperBase* self) {
125
- NoCapsuleReturned * obj = dynamic_cast <NoCapsuleReturned *>(self);
126
+ auto obj = dynamic_cast <NoCapsuleReturned *>(self);
126
127
assert (obj != nullptr );
127
128
PyObject* capsule = obj->as_pybind11_tests_class_sh_void_ptr_capsule_NoCapsuleReturned ();
128
129
return pybind11::reinterpret_steal<py::capsule>(capsule);
@@ -132,7 +133,7 @@ TEST_SUBMODULE(class_sh_void_ptr_capsule, m) {
132
133
.def (py::init<>())
133
134
.def (" as_pybind11_tests_class_sh_void_ptr_capsule_Valid" ,
134
135
[](HelperBase* self) {
135
- AsAnotherObject * obj = dynamic_cast <AsAnotherObject *>(self);
136
+ auto obj = dynamic_cast <AsAnotherObject *>(self);
136
137
assert (obj != nullptr );
137
138
PyObject* capsule = obj->as_pybind11_tests_class_sh_void_ptr_capsule_Valid ();
138
139
return pybind11::reinterpret_steal<py::capsule>(capsule);
0 commit comments