mirror of
https://github.com/pybind/pybind11.git
synced 2024-11-26 07:02:11 +00:00
note about nullptr default args
This commit is contained in:
parent
937d646bab
commit
c769fce280
@ -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
|
||||||
=================================================
|
=================================================
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user