[C++-sig] how to handle bare references with ashared_ptrHeldType

David Abrahams dave at boost-consulting.com
Tue Nov 1 16:21:24 CET 2005


"Gregory Price" <price at ELLINGTON.com> writes:

> Here's another version of that passage:
>
>   HeldType may be a smart pointer to T.  In this case
>   Boost.Python will allow Python T instances to hold
>   either a C++ T instance or a C++ HeldType instance.
>   If HeldType is shared_ptr<T>, a from_python converter
>   will be registered to accept a Python T instance holding 
>   a C++ T instance and return a shared_ptr<T> instance
>   with a custom deleter that decrements the Python refcount.
>
> Is this right?

Yes, although I don't think details about refcounts would be
appropriate at that point in the docs.

> In particular, have I correctly gathered the following
> about how Boost.Python works (and about its terminology):
>
>  When a Boost.Python function is called (in Python),
>  it finds a from_python converter to convert each
>  of the arguments to a C++ object of the required type.
>  Similarly, after invoking the underlying C++ function,
>  a to_python converter is found to convert its return value
>  into a Python object.

Right.

> Where in the documentation is this sort of orientation 
> material found?  (Or where should it be?)

I dunno.  Maybe in the tutorial somewhere?

-- 
Dave Abrahams
Boost Consulting
www.boost-consulting.com




More information about the Cplusplus-sig mailing list