Skip to content

Commit

Permalink
Merge pull request RobotLocomotion#8301 from EricCousineau-TRI/featur…
Browse files Browse the repository at this point in the history
…e/py_overload_cast_doc

pydrake_pybind: Docs for conventions on binding overloads
  • Loading branch information
EricCousineau-TRI authored Mar 13, 2018
2 parents 4cef1e4 + ab0cb1c commit 8519023
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions bindings/pydrake/pydrake_pybind.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,17 @@ objects from one container to another (e.g. transfering all `System`s
from `DiagramBuilder` to `Diagram` when calling
`DiagramBuilder.Build()`).
## Function Overloads
To bind function overloads, please try the following (in order):
- `py::overload_cast<Args>(func)`: See [the pybind11 documentation](http://pybind11.readthedocs.io/en/stable/classes.html#overloaded-methods).
This works about 80% of the time.
- `pydrake::overload_cast_explicit<Return, Args...>(func)`: When
`py::overload_cast` does not work (not always guaranteed to work).
- `static_cast`, as mentioned in the pybind11 documentation.
- Lambdas, e.g. `[](Args... args) -> auto&& { return func(args...); }`
(using perfect forwarding when appropriate).
# Interactive Debugging with Bazel
If you would like to interactively debug binding code (using IPython for
Expand Down

0 comments on commit 8519023

Please sign in to comment.