[C++-sig] Re: Custom WeakPtrs and "None"

Stefan Haller haller at ableton.com
Fri Nov 19 16:48:15 CET 2004

David Abrahams <dave at boost-consulting.com> wrote:

> haller at ableton.com (Stefan Haller) writes:
> > Yes, I don't want the Python variable itself to be set to None
> > literally, I know there's no way to do that.  I just want it to *look* a
> > bit more like None if the WeakPtr is NULL.  For example, I was hoping
> > that it is possible to play tricks with overloading __cmp__ (or some
> > such) to make the expression (weakptr == None) evaluate to True if
> > weakptr is not None, but its pointee is NULL.
> You could play that trick manually.  I would definitely *not* want to
> do that automatically in the library.

Could you please give me a hint how I would go about that?  I'm afraid I
don't know what exactly has to be done.

> Note that if you wrap this function:
>      X* identity(X* x) { return x; }
> you actually *will* get None back if you pass it one of these
> released weak_ptrs.

Yes, this is to be expected, right?  But I'm not sure how I can make use
of this in solving my problem.

Stefan Haller

More information about the Cplusplus-sig mailing list