Skip to content

Avoid C style casts in the docs, at least for pointers#2487

Merged
YannickJadoul merged 1 commit intopybind:masterfrom
bstaletic:overload_cast
Sep 14, 2020
Merged

Avoid C style casts in the docs, at least for pointers#2487
YannickJadoul merged 1 commit intopybind:masterfrom
bstaletic:overload_cast

Conversation

@bstaletic
Copy link
Copy Markdown
Collaborator

@bstaletic bstaletic commented Sep 14, 2020

When C++14, and thus py::overload_cast, isn't available the docs suggest a C style cast. A conservative static_cast seems a much better idea when working with function pointers.

EDIT: Let's hope I caught all C casts in the docs.

@tdegeus
Copy link
Copy Markdown
Contributor

tdegeus commented Sep 14, 2020

Thanks!

@bstaletic bstaletic force-pushed the overload_cast branch 2 times, most recently from fefd594 to c8b2720 Compare September 14, 2020 15:23
@bstaletic bstaletic changed the title Use static_cast for C++11 overload casting Avoid C style casts in the docs, at least for pointers Sep 14, 2020
Why only for pointers? Because C casts are hard to grep for.
Copy link
Copy Markdown
Collaborator

@YannickJadoul YannickJadoul left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, @bstaletic!

@YannickJadoul
Copy link
Copy Markdown
Collaborator

Let's just get this in before we forget. If there are more places where we can find C-style casts, we can always create more PRs :-)

@YannickJadoul YannickJadoul merged commit 32bb907 into pybind:master Sep 14, 2020
@bstaletic bstaletic deleted the overload_cast branch September 14, 2020 18:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants