Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
pybind11
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
open
pybind11
Commits
32bb9071
Unverified
Commit
32bb9071
authored
Sep 14, 2020
by
Boris Staletic
Committed by
GitHub
Sep 14, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Avoid C-style casts for pointers in docs (#2487)
Why only for pointers? Because C casts are hard to grep for.
parent
cc982ac1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
8 additions
and
8 deletions
+8
-8
docs/advanced/functions.rst
+1
-1
docs/advanced/misc.rst
+2
-2
docs/advanced/pycpp/numpy.rst
+3
-3
docs/classes.rst
+2
-2
No files found.
docs/advanced/functions.rst
View file @
32bb9071
...
@@ -360,7 +360,7 @@ like so:
...
@@ -360,7 +360,7 @@ like so:
.. code-block:: cpp
.. code-block:: cpp
py::class_<MyClass>("MyClass")
py::class_<MyClass>("MyClass")
.def("myFunction", py::arg("arg") =
(SomeType *) nullptr
);
.def("myFunction", py::arg("arg") =
static_cast<SomeType *>(nullptr)
);
Keyword-only arguments
Keyword-only arguments
======================
======================
...
...
docs/advanced/misc.rst
View file @
32bb9071
...
@@ -176,9 +176,9 @@ pybind11 version. Consider the following example:
...
@@ -176,9 +176,9 @@ pybind11 version. Consider the following example:
.. code-block:: cpp
.. code-block:: cpp
auto data =
(MyData *) py::get_shared_data("mydata"
);
auto data =
reinterpret_cast<MyData *>(py::get_shared_data("mydata")
);
if (!data)
if (!data)
data =
(MyData *) py::set_shared_data("mydata", new MyData(42
));
data =
static_cast<MyData *>(py::set_shared_data("mydata", new MyData(42)
));
If the above snippet was used in several separately compiled extension modules,
If the above snippet was used in several separately compiled extension modules,
the first one to be imported would create a ``MyData`` instance and associate
the first one to be imported would create a ``MyData`` instance and associate
...
...
docs/advanced/pycpp/numpy.rst
View file @
32bb9071
...
@@ -274,9 +274,9 @@ simply using ``vectorize``).
...
@@ -274,9 +274,9 @@ simply using ``vectorize``).
py::buffer_info buf3 = result.request();
py::buffer_info buf3 = result.request();
double *ptr1 =
(double *) buf1.ptr,
double *ptr1 =
static_cast<double *>(buf1.ptr);
*ptr2 = (double *) buf2.ptr,
double *ptr2 = static_cast<double *>(buf2.ptr);
*ptr3 = (double *) buf3.ptr
;
double *ptr3 = static_cast<double *>(buf3.ptr)
;
for (size_t idx = 0; idx < buf1.shape[0]; idx++)
for (size_t idx = 0; idx < buf1.shape[0]; idx++)
ptr3[idx] = ptr1[idx] + ptr2[idx];
ptr3[idx] = ptr1[idx] + ptr2[idx];
...
...
docs/classes.rst
View file @
32bb9071
...
@@ -373,8 +373,8 @@ sequence.
...
@@ -373,8 +373,8 @@ sequence.
py::class_<Pet>(m, "Pet")
py::class_<Pet>(m, "Pet")
.def(py::init<const std::string &, int>())
.def(py::init<const std::string &, int>())
.def("set",
(void (Pet::*)(int)) &Pet::set
, "Set the pet's age")
.def("set",
static_cast<void (Pet::*)(int)>(&Pet::set)
, "Set the pet's age")
.def("set",
(void (Pet::*)(const std::string &)) &Pet::set
, "Set the pet's name");
.def("set",
static_cast<void (Pet::*)(const std::string &)>(&Pet::set)
, "Set the pet's name");
The overload signatures are also visible in the method's docstring:
The overload signatures are also visible in the method's docstring:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment