Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2005-06-29 12:40:16

David Abrahams wrote:

> But seriously, that's not what I mean by reliable. I mean "a save
> function that's doing something sensical." Either the author of the
> save function tells the caller whether the object will be tracked, and
> the caller knows whether that behavior is appropriate given the
> context, or there's little point in making the save call to begin
> with. I mean, you're not going to do
> try
> {
> save_call_with_tracking(ar, x);
> }
> catch(tracking_error&)
> {
> save_call_without_tracking(ar, x);
> }
> right?

The user of my application will do something along these lines, yes. :-)

When you have a complex data structure, it isn't exactly trivial to
determine in advance whether it's "tracking safe" to attempt a save. If you
try to do that, you'll end up duplicating the save functionality. Consider
something like

vector< shared_ptr<A> > v;

where the A is an abstract class and the implementations are put into v from
separate parts of the program written by different people.

If you absolutely insist on an assert, you should provide a way to test
whether the precondition is met.

Boost list run by bdawes at, gregod at, cpdaniel at, john at