Re: weak pointer



The g-object-weak-ref is probably the neatest way of creating a weak
pointer class in glibmm, because it's a glib function. However, I have
never worked with it and probably won't be able to get something that
would be considered good enough to include in the distribution.

Making a working weak pointer class that simply inherits the RefPtr
and calles unreference on when created is something I could do. Then
you can ask the WeakPtr to create a RefPtr, just like BOOST does that
( http://www.boost.org/libs/smart_ptr/weak_ptr.htm ). The class would
then just check if the RefPtr is still valid before creating a copy of
it, throwing an Exception when it doesn't work.

Although the first is probably the best solution, I can't do that so
somebody else would have to be willing or knowledgeable enough to
create it.

Anyone on the team willing to take it up, or should I just start
working on the inherited solution and see how that works out?

Bram

On 7/24/07, Hubert Figuiere <hub figuiere net> wrote:

> I guess so, though I wonder if boost already has something, or can at
> least provide inspiration.
>
> This might also be useful:
> http://developer.gnome.org/doc/API/2.0/gobject/gobject-The-Base-Object-Type.html#g-object-weak-ref
>


boost::weak_ptr<> works in conjuction with boost::shared_ptr<>. So it is
not practicaly in this case. Taking inspiration from it however is possible.


Hub




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]