From: Andy Little (andy_at_[hidden])
Date: 2004-10-08 05:39:16
"Jonathan Turkanis" <technews_at_[hidden]> wrote
> "Andy Little" <andy_at_[hidden]> wrote
> > Hi,
> > Any interest in a shared_object?
> I have no idea what you mean, but I'll be posting something called
I guess what I am after is:
shared_object<T> my_obj; // Now my_obj refers to a T, which I can access
shared_object<T2> my_obj2 = my_obj1;
my_obj = my_obj1; // assume T is (say) a base of T1.
my_obj == my_obj1;
Reference gives a different guarantee than pointers. Ok Could still be cast
to a pointer but ....
T& x = my_obj(); // reference *feels* like more obvious semantics than
*Ideally* my_obj always holds something... never empty. That is I guess
problematic from the implementation viewpoint, as it may cause a large
number of allocations. However it makes the thing extremely simple to use.
Dont really want to have to do this all the time:
OTOH maybe could do:
// then make sure its not empty before going public...
As to implementation. Maybe slow.. maybe big, but typically what I would
want it for is for say switching views in a GUI app. Not critical on speed
or size. shared_object probably implements a garbage collector in fact.
> > In this case its the object that is shared, not the pointer....
> With shared_ptr, the object, not the pointer, is shared.
Aha ... descriptively named then... ;-)
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk