Boost logo

Boost Users :

From: Filip Konvička (filip.konvicka_at_[hidden])
Date: 2008-07-15 10:17:33


>> What is so bad in general about returning uninitialized smart pointers?
>> Is that more costly than throwing an exception? I mean, there is even
>> some support for testing a smart pointer for validity built into
>> shared_ptr, so why not use it where appropriate?
>>
>
> The only problem with returning a null pointer, or -1,
> or whatever in case of error is that it's easy to ignore
> at the calling scope, so the upper layers would not even know
> the error occurred. Exception, on the other hand, propagates
> up the stack enforcing more structured error handling.

I agree, but only if the case is an error. In my application, I have
several places where the "null" value is a regular result. That's what I
meant by saying "where appropriate".

Cheers,
Filip


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net