|
Boost : |
From: Peter Dimov (pdimov_at_[hidden])
Date: 2002-10-21 09:08:48
From: "Daniel Frey" <d.frey_at_[hidden]>
[...]
> >> What does "never throws" means
> >
> > It means that operator* doesn't throw when its requirements ("The stored
> > pointer must not be 0") are met, otherwise the behavior is undefined.
>
> Hm... I think that this point of view is perfectly reasonable if the
> condition that throws would be the result of a bug inside shared_ptr or
> the compiler, thus in actual code it cannot really happen. But the above
> BOOST_ASSERT guards against wrong use of the class. Wouldn't it be better
> to document a defined behaviour?
Depends on the point of view, but the general answer is "no". Imagine that
you are writing a shared_ptr implementation that must conform to the
documented interface. As things currently stand, you are free to make
operator* do whatever you think is appropriate for your situation. Had the
behavior been defined, you wouldn't have had a choice.
> For some applications, this may be of
> great use, e.g. a server that answers HTTP requests. Whatever happens
> inside a request, it should never kill the server itself, just the
> current operation. Or is there any reason why '// never throws' needs to
> be guaranteed and undefined behaviour for buggy uses of shared_ptr?
"// never throws" is not guaranteed for buggy uses.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk