File tree Expand file tree Collapse file tree 4 files changed +8
-8
lines changed
Expand file tree Collapse file tree 4 files changed +8
-8
lines changed Original file line number Diff line number Diff line change @@ -360,7 +360,7 @@ like so:
360360.. code-block :: cpp
361361
362362 py::class_<MyClass>("MyClass")
363- .def("myFunction", py::arg("arg") = ( SomeType *) nullptr);
363+ .def("myFunction", py::arg("arg") = static_cast< SomeType *>( nullptr) );
364364
365365 Keyword-only arguments
366366======================
Original file line number Diff line number Diff line change @@ -176,9 +176,9 @@ pybind11 version. Consider the following example:
176176
177177.. code-block :: cpp
178178
179- auto data = ( MyData *) py::get_shared_data("mydata");
179+ auto data = reinterpret_cast< MyData *>( py::get_shared_data("mydata") );
180180 if (!data)
181- data = ( MyData *) py::set_shared_data("mydata", new MyData(42));
181+ data = static_cast< MyData *>( py::set_shared_data("mydata", new MyData(42) ));
182182
183183 If the above snippet was used in several separately compiled extension modules,
184184the first one to be imported would create a ``MyData `` instance and associate
Original file line number Diff line number Diff line change @@ -274,9 +274,9 @@ simply using ``vectorize``).
274274
275275 py::buffer_info buf3 = result.request();
276276
277- double *ptr1 = ( double *) buf1.ptr,
278- *ptr2 = ( double *) buf2.ptr,
279- *ptr3 = ( double *) buf3.ptr;
277+ double *ptr1 = static_cast< double *>( buf1.ptr);
278+ double *ptr2 = static_cast< double *>( buf2.ptr);
279+ double *ptr3 = static_cast< double *>( buf3.ptr) ;
280280
281281 for (size_t idx = 0; idx < buf1.shape[0]; idx++)
282282 ptr3[idx] = ptr1[idx] + ptr2[idx];
Original file line number Diff line number Diff line change @@ -373,8 +373,8 @@ sequence.
373373
374374 py::class_<Pet>(m, "Pet")
375375 .def(py::init<const std::string &, int>())
376- .def("set", ( void (Pet::*)(int)) &Pet::set, "Set the pet's age")
377- .def("set", ( void (Pet::*)(const std::string &)) &Pet::set, "Set the pet's name");
376+ .def("set", static_cast< void (Pet::*)(int)>( &Pet::set) , "Set the pet's age")
377+ .def("set", static_cast< void (Pet::*)(const std::string &)>( &Pet::set) , "Set the pet's name");
378378
379379 The overload signatures are also visible in the method's docstring:
380380
You can’t perform that action at this time.
0 commit comments