Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
pybind11
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
open
pybind11
Commits
1853b65f
Commit
1853b65f
authored
Oct 18, 2015
by
Wenzel Jakob
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
a bit more documentation on reference counting wrappers
parent
7641c1dd
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
4 deletions
+13
-4
docs/advanced.rst
+13
-4
No files found.
docs/advanced.rst
View file @
1853b65f
...
...
@@ -427,18 +427,27 @@ references to the object. When wrapping a type named ``Type``, the default
value of this template parameter is ``std::unique_ptr<Type>``, which means that
the object is deallocated when Python's reference count goes to zero.
It is possible to switch to other types of
smart pointers, which is useful in
codebases that rely on them. For instance, the following snippet causes
``std::shared_ptr`` to be used instead.
It is possible to switch to other types of
reference counting wrappers or smart
pointers, which is useful in codebases that rely on them. For instance, the
following snippet causes
``std::shared_ptr`` to be used instead.
.. code-block:: cpp
py::class_<Example, std::shared_ptr<Example>> obj(m, "Example");
To enable transparent conversions for functions that take shared pointers as an
argument or that return them, a macro invocation similar to the following must
be declared at the top level before any binding code:
.. code-block:: cpp
PYBIND_DECLARE_HOLDER_TYPE(T, std::shared_ptr<T>);
.. seealso::
The file :file:`example/example8.cpp` contains a complete example that
demonstrates how to work with custom smart pointer types in more detail.
demonstrates how to work with custom reference-counting holder types in
more detail.
.. _custom_constructors:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment