[C++-sig] Re: Returning NULL from C++
David Abrahams
dave at boost-consulting.com
Thu Aug 14 01:34:41 CEST 2003
Ammar Hakim <ahakim777 at yahoo.com> writes:
> Hello All,
>
> How do I wrap a C++ function which does something like
> this:
>
> struct A {};
>
> A*
> get_A()
> {
> if(some_condition)
> return NULL;
> else
> return pointer_to_A;
> }
>
> I would like the NULL to be converted into a None in
> Python.
That functionality is built-in. However, the library will force you
to use a call policy to deal with the semantics of the pointer you're
returning in the other case (e.g. is it a new piece of memory or a
reference to an existing object?)
--
Dave Abrahams
Boost Consulting
www.boost-consulting.com
More information about the Cplusplus-sig
mailing list