Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2003-01-14 10:30:59


From: "Daniel Frey" <daniel.frey_at_[hidden]>
> Peter Dimov wrote:
> >
> > I'm thinking of renaming make_shared(weak_ptr), as the current
similarity
> > with make_pair is undesirable. The best replacement I can come up with
is
>
> I fail to see the problem. The similarity is IMHO helpful, as both
> deduce the type to generate from their parameters.

make_X(args) is typically equivalent to X<...>(args). However, make_shared
is not equivalent to the corresponding constructor. The constructor throws
an exception when the argument has expired(), and make_shared returns an
empty shared_ptr.

> > get_shared_ptr. I.e. instead of
>
> 'get' implies (at least to me), that it only fetches a pointer/reference
> to something which already exists.

In a way, this is exactly what make_shared/get_shared_ptr does; it fetches a
pointer to something which already exists, the object.

In a garbage collected language, where ordinary pointers keep objects alive,
it could have been named

T * weak_ptr::get() const;

or

T * get_pointer(weak_ptr const &);


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk