Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 14, 2020

Conversation

bstaletic
Copy link
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
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
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
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