[C++-sig] express pointer ownership
MM
finjulhich at gmail.com
Thu Aug 13 12:58:42 CEST 2015
On 13 August 2015 at 10:24, MM <finjulhich at gmail.com> wrote:
> I have the following class:
>
> class T {
> };
> // T has been exposed to python with class_
>
> and free function:
>
> void add_T( T* );
>
> Ownership of the T* is taken by this C++ function.
>
>
> If I create an instance of the python version of T, how do I "def" the
> add_T function?
>
> def("add_T", add_T)
>
> fails to compile.
>
Apologies. This compiled correctly.
This function:
const T* get_T( const std::string& name );
failed to compile.
so the T pointer is owner by a container in the c++ world, it gets stored
there by add_T,
then the get_T returns a raw pointer to it. I want to tell python to let
c++ manage it.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20150813/b6b31292/attachment.html>
More information about the Cplusplus-sig
mailing list