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:
360
360
.. code-block :: cpp
361
361
362
362
py::class_<MyClass>("MyClass")
363
- .def("myFunction", py::arg("arg") = ( SomeType *) nullptr);
363
+ .def("myFunction", py::arg("arg") = static_cast< SomeType *>( nullptr) );
364
364
365
365
Keyword-only arguments
366
366
======================
Original file line number Diff line number Diff line change @@ -176,9 +176,9 @@ pybind11 version. Consider the following example:
176
176
177
177
.. code-block :: cpp
178
178
179
- auto data = ( MyData *) py::get_shared_data("mydata");
179
+ auto data = reinterpret_cast< MyData *>( py::get_shared_data("mydata") );
180
180
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) ));
182
182
183
183
If the above snippet was used in several separately compiled extension modules,
184
184
the 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``).
274
274
275
275
py::buffer_info buf3 = result.request();
276
276
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
+ *ptr2 = static_cast< double *>( buf2.ptr) ,
279
+ *ptr3 = static_cast< double *>( buf3.ptr) ;
280
280
281
281
for (size_t idx = 0; idx < buf1.shape[0]; idx++)
282
282
ptr3[idx] = ptr1[idx] + ptr2[idx];
Original file line number Diff line number Diff line change @@ -373,8 +373,8 @@ sequence.
373
373
374
374
py::class_<Pet>(m, "Pet")
375
375
.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");
378
378
379
379
The overload signatures are also visible in the method's docstring:
380
380
You can’t perform that action at this time.
0 commit comments