Boost logo

Boost :

From: Marco Costalba (mcostalba_at_[hidden])
Date: 2008-03-22 14:03:05


On Sat, Mar 22, 2008 at 12:12 PM, Kevin Scarr <kscarr_at_[hidden]> wrote:
> Marco Costalba wrote:
>
> On the surface it seems that throwing at least allows the possibility of
> graceful termination for programs (I do realise uncaught exceptions
> still abort the program without cleanup), so I suspect there must be
> something deeper that I have missed.
>

Throwing an exception it's a possibility. Actually I have not really
considered it, but probably it's my fault.

Normally I mentally associate exceptions with something that can go
wrong in some "strange" way, eventually out of the control of the
caller.

It comes much more naturally to me to think at this:

if (ptr)
   ptr->doSomething();

then this

try {

  ptr->doSomething();

} catch (ptr_is_null)

In our case it is possible to use is_set() to check for a NULL pointer
before to call the function, but, again, this is only my way to think,
perhaps exceptions are the more idiomatic way to code in this case.

Anyhow exception is a perfectly viable solution.

Thanks for the suggestion
Marco


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