Boost logo

Boost Users :

From: Toon Knapen (toon.knapen_at_[hidden])
Date: 2002-05-04 14:49:29


When creating a shared_ptr<T> from a weak_ptr<T>, I want the shared_ptr<T> to
use the same count as the shared_ptr the weak_ptr was constructed from.

I could create a new shared_ptr, based on the pointer I can get() from the
weak_ptr. But in this case, this shared_ptr will keep its own count.

Let me fill you in on my use-case. An object creates some big data-structure
on request of its clients, taking into account some options specified by the
client while making the request. Now I'd like the server-object to keep a
weak_ptr to these big data-structure to provide quickly the same result once
another client performs an identical request. The server should however not
keep a shared_ptr because otherwise all datastructure will stay in memory.
And therefor I need to create a shared_ptr from a weak_ptr.

thanks,
toon


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net