Commit c769fce2 by Wenzel Jakob

note about nullptr default args

parent 937d646b
...@@ -1007,6 +1007,15 @@ default argument manually using the ``arg_t`` notation: ...@@ -1007,6 +1007,15 @@ default argument manually using the ``arg_t`` notation:
py::class_<MyClass>("MyClass") py::class_<MyClass>("MyClass")
.def("myFunction", py::arg_t<SomeType>("arg", SomeType(123), "SomeType(123)")); .def("myFunction", py::arg_t<SomeType>("arg", SomeType(123), "SomeType(123)"));
Sometimes it may be necessary to pass a null pointer value as a default
argument. In this case, remember to cast it to the underlying type in question,
like so:
.. code-block:: cpp
py::class_<MyClass>("MyClass")
.def("myFunction", py::arg("arg") = (SomeType *) nullptr);
Partitioning code over multiple extension modules Partitioning code over multiple extension modules
================================================= =================================================
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment