mirror of
https://github.com/pybind/pybind11.git
synced 2024-11-25 22:52:01 +00:00
minor doc touchups
This commit is contained in:
parent
1fa7422284
commit
0b63231bae
@ -663,17 +663,19 @@ In addition to the above return value policies, further `call policies` can be
|
|||||||
specified to indicate dependencies between parameters. There is currently just
|
specified to indicate dependencies between parameters. There is currently just
|
||||||
one policy named ``keep_alive<Nurse, Patient>``, which indicates that the
|
one policy named ``keep_alive<Nurse, Patient>``, which indicates that the
|
||||||
argument with index ``Patient`` should be kept alive at least until the
|
argument with index ``Patient`` should be kept alive at least until the
|
||||||
argument with index ``Nurse`` is freed by the garbage collector, as long as the
|
argument with index ``Nurse`` is freed by the garbage collector. Argument
|
||||||
nurse object supports weak references (pybind11 extension classes all support
|
indices start at one, while zero refers to the return value. For methods, index
|
||||||
weak references). If the nurse object does not support weak references and is
|
``1`` refers to the implicit ``this`` pointer, while regular arguments begin at
|
||||||
not None an appropriate exception will be thrown. Argument indices start at
|
index ``2``. Arbitrarily many call policies can be specified. When a ``Nurse``
|
||||||
one, while zero refers to the return value. For methods, index one refers to
|
with value ``None`` is detected at runtime, the call policy does nothing.
|
||||||
the implicit ``this`` pointer, while regular arguments begin at index two.
|
|
||||||
Arbitrarily many call policies can be specified.
|
|
||||||
|
|
||||||
Consider the following example: the binding code for a list append operation
|
This feature internally relies on the ability to create a *weak reference* to
|
||||||
that ties the lifetime of the newly added element to the underlying container
|
the nurse object, which is permitted by all classes exposed via pybind11. When
|
||||||
might be declared as follows:
|
the nurse object does not support weak references, an exception will be thrown.
|
||||||
|
|
||||||
|
Consider the following example: here, the binding code for a list append
|
||||||
|
operation ties the lifetime of the newly added element to the underlying
|
||||||
|
container:
|
||||||
|
|
||||||
.. code-block:: cpp
|
.. code-block:: cpp
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user