@@ -20,6 +20,7 @@ namespace class_sh_void_ptr_capsule {
2020// Conveniently, the helper also serves to keep track of `capsule_generated`.
2121struct HelperBase {
2222 HelperBase () = default ;
23+ HelperBase (const HelperBase &) = delete ;
2324 virtual ~HelperBase () = default ;
2425
2526 bool capsule_generated = false ;
@@ -45,7 +46,7 @@ struct NoConversion: public HelperBase {
4546};
4647
4748struct NoCapsuleReturned : public HelperBase {
48- int get () const { return 103 ; }
49+ int get () const override { return 103 ; }
4950
5051 PyObject* as_pybind11_tests_class_sh_void_ptr_capsule_NoCapsuleReturned () {
5152 capsule_generated = true ;
@@ -72,7 +73,7 @@ int get_from_valid_capsule(const Valid* c) {
7273 return c->get ();
7374}
7475
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) {
7677 return c->get ();
7778}
7879
@@ -109,7 +110,7 @@ TEST_SUBMODULE(class_sh_void_ptr_capsule, m) {
109110 .def (py::init<>())
110111 .def (" as_pybind11_tests_class_sh_void_ptr_capsule_Valid" ,
111112 [](HelperBase* self) {
112- Valid * obj = dynamic_cast <Valid *>(self);
113+ auto obj = dynamic_cast <Valid *>(self);
113114 assert (obj != nullptr );
114115 PyObject* capsule = obj->as_pybind11_tests_class_sh_void_ptr_capsule_Valid ();
115116 return pybind11::reinterpret_steal<py::capsule>(capsule);
@@ -122,7 +123,7 @@ TEST_SUBMODULE(class_sh_void_ptr_capsule, m) {
122123 .def (py::init<>())
123124 .def (" as_pybind11_tests_class_sh_void_ptr_capsule_NoCapsuleReturned" ,
124125 [](HelperBase* self) {
125- NoCapsuleReturned * obj = dynamic_cast <NoCapsuleReturned *>(self);
126+ auto obj = dynamic_cast <NoCapsuleReturned *>(self);
126127 assert (obj != nullptr );
127128 PyObject* capsule = obj->as_pybind11_tests_class_sh_void_ptr_capsule_NoCapsuleReturned ();
128129 return pybind11::reinterpret_steal<py::capsule>(capsule);
@@ -132,7 +133,7 @@ TEST_SUBMODULE(class_sh_void_ptr_capsule, m) {
132133 .def (py::init<>())
133134 .def (" as_pybind11_tests_class_sh_void_ptr_capsule_Valid" ,
134135 [](HelperBase* self) {
135- AsAnotherObject * obj = dynamic_cast <AsAnotherObject *>(self);
136+ auto obj = dynamic_cast <AsAnotherObject *>(self);
136137 assert (obj != nullptr );
137138 PyObject* capsule = obj->as_pybind11_tests_class_sh_void_ptr_capsule_Valid ();
138139 return pybind11::reinterpret_steal<py::capsule>(capsule);
0 commit comments